天天看點

從模版中找到控件的方法和找到樣式的方法

原文:

從模版中找到控件的方法和找到樣式的方法

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;

};