I want to create a button in c# with no content but just a image within it.
I dont know how to use the setter. Can anyone enlighten me?
Setter setter = new Setter();
setter.Property = Image.SourceProperty;
setter.Value = "asd.jpg"; //<--error
Style Rstyle = new Style();
Rstyle.TargetType = typeof(Button);
Rstyle.Setters.Add(setter);
Button _Button = new Button()
{
Width = 41,
Height = 41
};
_Button.Style = Rstyle;
What should i put at setter.Value to obtain the image which resides in the project directory. “asd.jpg”
For the matter of this question Setters are not necessary. Setters are used in Triggers and Styles, whether in C# or in XAML.
Just use this code.