Segue código XAML:
<TextBox /> <TextBox.Background> <ImageBrush x:Name="image_background" Stretch="Fill" TileMode="None" AlignmentX="Left" AlignmentY="Center" /> </TextBox.Background> </TextBox>
Segue código C#: (O código a seguir, tem um evento click
, para mudar a imagem do textbox de cor preto)
image_background.ImageSource = CreateBitmapSource(System.Windows.Media.Color.FromArgb(255, 0, 0, 0)); // Black Color
O que funciona é só no evento Loaded
:
private void Window_Loaded(object sender, RoutedEventArgs e) { // aqui consigo mudar a cor image_background.ImageSource = CreateBitmapSource(System.Windows.Media.Color.FromArgb(255, 0, 255, 0)); }
Alguma solução para mudar a cor ?