Subscribe to Question

How to fill the background of a button in WPF at run time?



Nov 21, 2007 - williamgates_uk

Answers

In .xaml file add a button and resource which is as follows :

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowsApplication7" Height="300" Width="300"
>









In .cs file add the below mentioned code and you will see
the button using the resource at run time not compile time .

public Window1()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(changeColorBK);
}

void changeColorBK(object s, RoutedEventArgs e)
{
button1.Background = Resources["bru"] as Brush;
}

Dec 03, 2007 -
seemajain8212
1 - 1 of 1 First | Previous | Next | Last  
Newsletter
Copyright © 2014 VisualBuilder. All rights reserved