2012-04-17 3 views
0

ブラウザで3種類のタブ項目があると仮定し、ウィンドウアプリケーションを開くと同時にすべてのタブをロードしてレンダリングします。複数のタブがWPF、C#で並行してレンダリングされますか?

私の質問:並列またはスレッドでレンダリングできるすべてのタブにはアプローチがありますか?

+3

非常にアイデアが唯一の1タブを一度にレンダリングすることです。 –

答えて

1

デフォルトContentPresenterの代わりにListBoxを使用するカスタムテンプレートを使用して、それをハックすることができます:TabControlのの

<TabControl> 
     <TabItem Header="A"> 
      <WebBrowser Source="http://www.google.com/" /> 
     </TabItem> 
     <TabItem Header="B"> 
      <WebBrowser Source="http://www.bing.com/" /> 
     </TabItem> 
     <TabItem Header="C"> 
      <WebBrowser Source="http://www.yahoo.com/" /> 
     </TabItem> 
     <Control.Template> 
      <ControlTemplate TargetType="TabControl"> 
       <DockPanel> 
        <TabPanel IsItemsHost="True" 
           DockPanel.Dock="{TemplateBinding TabStripPlacement}" /> 
        <ListBox ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Items}" 
          SelectedIndex="{TemplateBinding SelectedIndex}"> 
         <ItemsControl.ItemsPanel> 
          <ItemsPanelTemplate> 
           <Grid /> 
          </ItemsPanelTemplate> 
         </ItemsControl.ItemsPanel> 
         <ItemsControl.ItemContainerStyle> 
          <Style TargetType="ListBoxItem"> 
           <Setter Property="Template"> 
            <Setter.Value> 
             <ControlTemplate TargetType="ListBoxItem"> 
              <ContentPresenter Content="{Binding Content}" 
                   ContentTemplate="{Binding ContentTemplate}" 
                   ContentTemplateSelector="{Binding ContentTemplateSelector}" /> 
             </ControlTemplate> 
            </Setter.Value> 
           </Setter> 
           <Setter Property="Visibility" 
             Value="Hidden" /> 
           <Style.Triggers> 
            <Trigger Property="IsSelected" 
              Value="True"> 
             <Setter Property="Visibility" 
               Value="Visible" /> 
            </Trigger> 
           </Style.Triggers> 
          </Style> 
         </ItemsControl.ItemContainerStyle> 
        </ListBox> 
       </DockPanel> 
      </ControlTemplate> 
     </Control.Template> 
    </TabControl> 
+0

レンダリングは1つのスレッドでも発生しますが、 'WebBrowser'コントロールの性質上、ページはバックグラウンドで読み込まれることに注意してください。 –

0

ウィンドウは、独自のUIスレッドで開始できます。しかし、タブは現在のウィンドウが開始されたUIスレッドでレンダリングされます。

関連する問題