XAML:
<TextBox />
<TextBox.Background>
<ImageBrush x:Name="image_background" Stretch="Fill" TileMode="None" AlignmentX="Left" AlignmentY="Center" />
</TextBox.Background>
</TextBox>
C #: (The following code has an event click
, to change the image of the black color textbox)
image_background.ImageSource = CreateBitmapSource(System.Windows.Media.Color.FromArgb(255, 0, 0, 0)); // Black Color
What works is only in event 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));
}
Any solution to change color?