从模版中找到控件的方法和找到样式的方法

时间:2015-01-17 23:30:43   收藏:0   阅读:235

this.Style = (Style) App.Current.Resources["BaseWindowStyle"];

运行下段代码一定要加载样式完成后

i最好是在 Loaded 事件运行完成后加载  

ControlTemplate baseWindowTemplate = (ControlTemplate)App.Current.Resources["BaseWindowControlTemplate"];

Button minBtn = (Button)baseWindowTemplate.FindName("btnMin", this);
minBtn.Click += delegate
{
this.WindowState = WindowState.Minimized;
};

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!