I am creating the button in silver light dynamically as
HistoryButtton = new Button();
HistoryButtton.Content = "History";
HistoryButtton.Height = GetPercentageValue(TotalHeight, 8);
HistoryButtton.Width = GetPercentageValue(TotalHeight, 15);
I tried this solution
ImageBrush brush = new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri(@"Images/history.png", UriKind.Relative));
HistoryButtton.Background = brush;
But its not working.
I also tried this solution
Uri uri = new Uri("/Images/history.png", UriKind.Relative);
BitmapImage imgSource = new BitmapImage(uri);
Image image = new Image();
image.Source = imgSource;
HistoryButtton.Content = image;
But this solution also not working. Please help me.Thanks in advance.
try to change your Uri first parameter to be like this
“/SolutionName;component/Images/history.png”
replace SolutionName with your Solution name.