c# - When extending treeview, do I need to specify a control template or does it use the default control template -
starting make custom treeview , wondering why can't seem display. didn't change xaml except replacing treeview multiselecttreeview, yet doesn't display. if extend treeview, extended class inherit default control template of parent class?
public class multiselecttreeview:treeview { #region data members private treeviewitem lastitem = null; private observablecollection<treeviewitem> selectedtreeviewitemslist = new observablecollection<treeviewitem>(); public observablecollection<treeviewitem> selectednodes { { return selectedtreeviewitemslist; } private set { selectedtreeviewitemslist.clear(); selectedtreeviewitemslist = value; } } public bool ctrldown { { return keyboard.iskeydown(key.leftctrl) || keyboard.iskeydown(key.rightctrl); } } public bool shiftdown { { return keyboard.iskeydown(key.leftshift) || keyboard.iskeydown(key.rightshift); } } #endregion data members #region constructors /// <summary> /// static constructor defines key used find default theme style control /// </summary> static multiselecttreeview() { defaultstylekeyproperty.overridemetadata( typeof(multiselecttreeview), new frameworkpropertymetadata(typeof(multiselecttreeview))); } public multiselecttreeview() { this.selecteditemchanged += new routedpropertychangedeventhandler<object>(multiselecttreeview_selecteditemchanged); this.background = brushes.blue; this.foreground = brushes.yellow; }
by default, use default style treeview
, specified different defaultstylekey
in static constructor:
defaultstylekeyproperty.overridemetadata( typeof(multiselecttreeview), new frameworkpropertymetadata(typeof(multiselecttreeview)));
if this, must create style {x:type multiselecttreeview}
key.
if want default style, remove statement code.
Comments
Post a Comment