Trigger for ComboBox in Silverlight
        Posted  
        
            by Budda
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Budda
        
        
        
        Published on 2010-05-29T22:05:25Z
        Indexed on 
            2010/05/29
            22:12 UTC
        
        
        Read the original article
        Hit count: 532
        
- Is there any possibility to display selected item of the ComboBox (after popup closing) in a way that is different from its displaying in DropDown List (There are players number and name in the dropdown list, but after list closing I want to see only its number). 
- How can I change a background for the player with some Flag? 
As far as I know, all of that can be done with triggers, but are they supported in Silverlight 4, VS2010, Silverlight Toolkit 4? In my case the following code
        <ComboBox ItemsSource="{Binding PlayersAll}"
                  SelectedItem="{Binding Path=SelectedPlayer, Mode=TwoWay}"
                  >
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <ToolkitControls:WrapPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding TeamNumber}"/>
                        <TextBlock Text=" - "/>
                        <TextBlock Text="{Binding ShortName}"/>
                    </ToolkitControls:WrapPanel>
                    <DataTemplate.Triggers>
                        <Trigger Property="HasError" Value="True">
                            <Setter Property="Background" TargetName="FlagSet" Value="Red"/>
                        </Trigger>
                    </DataTemplate.Triggers>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
gives an error:
The property 'Triggers' does not exist on the type 'DataTemplate' in the XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'
what is wrong here? Here are my namespaces:
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
       xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
       xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
       xmlns:ToolkitControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
© Stack Overflow or respective owner