hello all
i have project To Formatting RichTextBox Text
and have ComboBox that Display colors as [Color it self : Color Name ]
:
<ComboBox Name="cboColors" Width="80" IsTextSearchEnabled="True" ItemsSource="{Binding Source={StaticResource colorPropertiesOdp}}" SelectedValuePath="Name" SelectionChanged="cboColors_SelectionChanged"><ComboBox.ItemTemplate><DataTemplate><StackPanel Orientation="Horizontal" Height="18" Margin="0,0,0,2"><Border BorderThickness="1" CornerRadius="2" BorderBrush="Black" Width="50" VerticalAlignment="Stretch" Background="{Binding Name}"/><TextBlock Text="{Binding Name}" Margin="8,0,0,0"/></StackPanel></DataTemplate></ComboBox.ItemTemplate></ComboBox>
i want when user Select Color from this combo to apply it to RichTextBox
Like :
txtMessage.Foreground = new SolidColorBrush( (Color)cboColors.SelectedItem);
but i get error :
//Specified cast is not valid.