开始制作自定义树视图,我想知道为什么我似乎无法显示它。除了用 MultiSelectTreeView 替换 treeview 之外,我没有更改我的 xaml,但它没有显示。如果我扩展treeview,扩展类是否继承父类的默认控件模板?
public class MultiSelectTreeView:TreeView
{
#region Data Members
private TreeViewItem LastItem = null;
private ObservableCollection<TreeViewItem> SelectedTreeViewItemsList = new ObservableCollection<TreeViewItem>();
public ObservableCollection<TreeViewItem> SelectedNodes
{
get
{
return SelectedTreeViewItemsList;
}
private set
{
SelectedTreeViewItemsList.Clear();
SelectedTreeViewItemsList = value;
}
}
public bool CtrlDown
{
get
{
return Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl);
}
}
public bool ShiftDown
{
get
{
return Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift);
}
}
#endregion Data Members
#region Constructors
/// <summary>
/// Static Constructor defines the key used to find the default theme style for this 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;
}