在我的应用程序中,我正在创建一个这样的样式:
Dim ButtonStyle as new Style(GetType(Button))
ButtonStyle.Setters.Add(New Setter(BackgroundProperty,Brushes.Gray))
Resources.Add("ButtonStyle", ButtonsStyle)
我希望在应用程序退出时保存此样式,以便下次运行应用程序时会加载我的新样式。有可能吗?
答案 0 :(得分:0)
在c#抱歉:
public partial class App : Application
{
public App()
{
if (string.IsNullOrWhiteSpace(Settings.Default.Resources))
{
Style buttonStyle = new Style(typeof(Button));
buttonStyle.Setters.Add(new Setter(Button.BackgroundProperty, Brushes.Red));
Resources.Add(typeof(Button), buttonStyle);
}
else
Resources = XamlReader.Parse(Settings.Default.Resources) as ResourceDictionary;
}
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
// Save styles
Settings.Default.Resources = XamlWriter.Save(Resources);
Settings.Default.Save();
}
}