2009-09-21 4 views
0

#WPF에서 ItemTemplateSelectors가 있습니다. 그러나 바인딩 된 객체의 데이터 유형을 기반으로 ItemContainerStyle을 선택할 수 있습니까?WPF에서 데이터 바인딩 된 내용을 기반으로 ItemContainerStyle 선택

저는 스 캐터 뷰를 데이터 바인딩합니다. DataContext의 객체를 기반으로 생성 된 ScatterViewItems의 일부 속성을 설정하려고합니다. 스타일에 대한 ItemTemplateSelector와 비슷한 메커니즘이 좋습니다. 그게 가능한가? 나는 현재 효과를 나타 내기 위해 표시하고있는 객체의 속성에 바인딩하고 있지만 오버 헤드와 너무 복잡하고 (가장 중요한 것은 우리 XU 디자이너가 직접 할 수없는) 느낌입니다.

이것은 현재 사용중인 XAML입니다. 귀하의 도움을 크게 주시면 감사하겠습니다.

 <s:ScatterView x:Name="topicsViewer"> 
    <s:ScatterView.ItemTemplateSelector> 
    <local:TopicViewerDataTemplateSelector> 
    <DataTemplate DataType="{x:Type mvc:S7VideoTopic}"> 
     <Grid> 
     <ContentPresenter Content="{Binding MediaElement}" /> 
     <s:SurfaceButton Visibility="{Binding MailToVisible}" x:Name="mailto" Tag="{Binding Titel}" Click="mailto_Click" HorizontalAlignment="Right" VerticalAlignment="Top" Background="Transparent" Width="62" Height="36"> 
     <Image Source="/Resources/MailTo.png" /> 
     </s:SurfaceButton> 
     <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center" Height="32"> 
     <s:SurfaceButton Tag="{Binding MediaElement}" x:Name="btnPlay" Click="btnPlay_Click"> 
     <Image Source="/Resources/control_play.png" /> 
     </s:SurfaceButton> 
     <s:SurfaceButton Tag="{Binding MediaElement}" x:Name="btnPause" Click="btnPause_Click"> 
     <Image Source="/Resources/control_pause.png" /> 
     </s:SurfaceButton> 
     <s:SurfaceButton Tag="{Binding MediaElement}" x:Name="btnStop" Click="btnStop_Click"> 
     <Image Source="/Resources/control_stop.png" /> 
     </s:SurfaceButton> 
     </StackPanel> 
     </Grid> 
    </DataTemplate> 
    <DataTemplate DataType="{x:Type mvc:S7ImageTopic}"> 
     <Grid> 
     <ContentPresenter Content="{Binding Resource}" /> 
     <s:SurfaceButton Visibility="{Binding MailToVisible}" x:Name="mailto" Tag="{Binding Titel}" Click="mailto_Click" HorizontalAlignment="Right" VerticalAlignment="Top" Background="Transparent" Width="62" Height="36"> 
     <Image Source="/Resources/MailTo.png" /> 
     </s:SurfaceButton> 
     </Grid> 
    </DataTemplate> 
    <DataTemplate DataType="{x:Type local:Kassa}"> 
     <ContentPresenter Content="{Binding}" Width="300" Height="355" /> 
    </DataTemplate> 
    </local:TopicViewerDataTemplateSelector> 
    </s:ScatterView.ItemTemplateSelector> 
    <s:ScatterView.ItemContainerStyle> 
    <Style TargetType="s:ScatterViewItem"> 
    <Setter Property="MinWidth" Value="200" /> 
    <Setter Property="MinHeight" Value="150" /> 
    <Setter Property="MaxWidth" Value="800" /> 
    <Setter Property="MaxHeight" Value="700" /> 
    <Setter Property="Width" Value="{Binding DefaultWidth}" /> 
    <Setter Property="Height" Value="{Binding DefaultHeight}" /> 
    <Setter Property="s:ScatterViewItem.CanMove" Value="{Binding CanMove}" /> 
    <Setter Property="s:ScatterViewItem.CanScale" Value="{Binding CanScale}" /> 
    <Setter Property="s:ScatterViewItem.CanRotate" Value="{Binding CanRotate}" /> 
    <Setter Property="Background" Value="Transparent" /> 
    </Style> 
    </s:ScatterView.ItemContainerStyle> 
    </s:ScatterView> 

바트 Roozendaal, Sevensteps

답변

1

방법이 ItemContainerStyleSelector (대만족!) ... 죄송합니다, 그것은 긴 밤

이었다 사용에 대한
관련 문제