Ok, so I know a little bit about GUI development, and am new to Windows 8 (Modern UI) I'd also like to do this with C# (no XAML) if possible.
Style What I'm trying to do here is create a style I can apply to a button created somewhere else.
public static Style firstButtonStyle()
{
firstButton = new Style(typeof(Button));
ControlTemplate btnControl = new ControlTemplate();
//firstButton.Setters.Add(new Setter(Button.TemplateProperty, btnControl));
firstButton.Setters.Add(new Setter(Button.BackgroundProperty, new SolidColorBrush(Windows.UI.Colors.Blue)));
firstButton.Setters.Add(new Setter(Button.IsPointerOverProperty, new SolidColorBrush(Windows.UI.Colors.PaleGreen)));
firstButton.Setters.Add(new Setter(Button.IsPressedProperty, Windows.UI.Colors.Beige));
firstButton.Setters.Add(new Setter(Button.ForegroundProperty, Windows.UI.Colors.Red));
return firstButton;
}
Application
This is where the button is created and the style applied.
private Button enterButtonCreation(string text)
{
Button enterButton = new Button();
enterButton.Content = text;
enterButton.Margin = new Thickness(200, 80, 20, 0);
Style firstButtonStyl = WikierStyle.firstButtonStyle();
enterButton.Style = firstButtonStyl;
enterButton.Background = new SolidColorBrush(Windows.UI.Colors.Silver);
return enterButton;
}
I can change the background silver using .Background, but when using .BackgroundProperty nothing seems to happen.