但是發現這太難了~~ 如果想要加一下比較特別的功能 或是 Usability
UI跟Logics其實是有隱含的共識與假設的........ 這部分TemplatePart就可以用來解決這方面的問題
可以參考以下這二個link
http://www.cnblogs.com/zhouyinhui/archive/2007/12/01/979715.html
http://pavanpodila.spaces.live.com/blog/cns!9C9E888164859398!634.entry
怎麼寫呢? 例如 ( from 以上Link的Copy & Paste)
[TemplatePartAttribute(Name = "PART_EditableTextBox", Type = typeof(TextBox))]
[TemplatePartAttribute(Name = "PART_Popup", Type = typeof(Popup))]
[LocalizabilityAttribute(LocalizationCategory.ComboBox)]
[StyleTypedPropertyAttribute(Property = "ItemContainerStyle", StyleTargetType = typeof(ComboBoxItem))]
public class ComboBox : Selector
[TemplatePartAttribute(Name = "PART_Popup", Type = typeof(Popup))]
[LocalizabilityAttribute(LocalizationCategory.ComboBox)]
[StyleTypedPropertyAttribute(Property = "ItemContainerStyle", StyleTargetType = typeof(ComboBoxItem))]
public class ComboBox : Selector
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
Button mybtn = base.GetTemplateChild("PART_BTN");
if (mybtn != null)
{
mybtn.Click += new RoutedEventHandler(mybtn_Click);
}
}
{
base.OnApplyTemplate();
Button mybtn = base.GetTemplateChild("PART_BTN");
if (mybtn != null)
{
mybtn.Click += new RoutedEventHandler(mybtn_Click);
}
}
沒有留言:
張貼留言