Skip to content

Instantly share code, notes, and snippets.

/code.xaml Secret

Created June 6, 2014 17:46
Show Gist options
  • Save anonymous/b63c56878ea59aaee4cc to your computer and use it in GitHub Desktop.
Save anonymous/b63c56878ea59aaee4cc to your computer and use it in GitHub Desktop.
<ControlTemplate x:Key="SimpleTemplate">
<StackPanel Orientation="Horizontal">
<StackPanel Margin="7 0 0 0">
<TextBlock Margin="0 0 0 0"
Text="{Binding Name}"
FontSize="12" />
<TextBlock Text="{Binding Status}"
FontSize="12" />
</StackPanel>
</StackPanel>
</ControlTemplate>
<ControlTemplate x:Key="ExtendedTemplate">
<StackPanel Orientation="Horizontal">
<StackPanel Margin="15 0 0 0">
<TextBlock Margin="0 0 0 0"
Text="{Binding Name}"
FontSize="11"
FontWeight="Bold" />
<TextBlock Text="{Binding Status}"
FontSize="11" />
</StackPanel>
</StackPanel>
</ControlTemplate>
<DataTemplate x:Key="MyTemplate">
<Control x:Name="theControl"
Focusable="False"
Template="{StaticResource ExtendedTemplate}" />
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ComboBoxItem}}, Path=IsSelected}"
Value="True">
<Setter TargetName="theControl"
Property="Template"
Value="{StaticResource SimpleTemplate}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment