<UserControl x:Class="MECF.Framework.UI.Core.Control.ColorPicker"
             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:local="clr-namespace:MECF.Framework.UI.Core.Control"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             x:Name="Root"
             d:DesignHeight="450"
             d:DesignWidth="800"
             mc:Ignorable="d">
    <UserControl.Resources>

        <Style x:Key="ComboBox_IsChangedStyle"
               BasedOn="{StaticResource {x:Type ComboBox}}"
               TargetType="ComboBox">
            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=Root, Path=IsColorChanged}" Value="True">
                    <Setter Property="Background" Value="#a2f393" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <Grid>
        <ComboBox x:Name="ColorCombo"
                  VerticalContentAlignment="Center"
                  ItemsSource="{Binding AvailableColors, ElementName=Root}"
                  SelectedValue="{Binding SelectedColor, ElementName=Root, Mode=TwoWay}"
                  SelectedValuePath="Color"
                  Style="{StaticResource ComboBox_IsChangedStyle}">

            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Border Width="16"
                                Height="16"
                                Margin="0,0,8,0"
                                BorderBrush="Gray"
                                BorderThickness="1">
                            <Border.Background>
                                <SolidColorBrush Color="{Binding Color}" />
                            </Border.Background>
                        </Border>
                        <TextBlock VerticalAlignment="Center" Text="{Binding Name}" />
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
    </Grid>
</UserControl>
