I am converting my application from WinFrom to WPF. I want equivalent to WPF of following line of code :
txtbox.SelectionColor = Color.Green;
I am converting my application from WinFrom to WPF. I want equivalent to WPF of following line of code :
txtbox.SelectionColor = Color.Green;
You need to use SelectionBrush
for WPF -
textBox.SelectionBrush = new SolidColorBrush(Colors.Green);
Or simply -
textBox.SelectionBrush = Brushes.Green;
Changing textBox highlighted text color
is not possible
in WPF. Check this out for more details.
However you can achieve that for RixhTextBox
though. Details can be found here - Change selected text color in RichTextBox.
just do something like this in your xaml code
<TextBox SelectionBrush="Green"/>
or in your code behind
txtBox.SelectionBrush = new SolidColorBrush(Colors.Green);