You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

  1. using System.Windows;
  2. using System.Windows.Controls;
  3. namespace BPA.UIControl
  4. {
  5. /// <summary>
  6. /// 树形列表
  7. /// </summary>
  8. [StyleTypedProperty(Property = "ItemContainerStyle", StyleTargetType = typeof(TreeListViewItem))]
  9. public class TreeListView : TreeView
  10. {
  11. /// <summary>
  12. /// 列集合
  13. /// </summary>
  14. public static readonly DependencyProperty ColumnsProperty =
  15. DependencyProperty.Register("Columns", typeof(GridViewColumnCollection), typeof(TreeListView), new PropertyMetadata(new GridViewColumnCollection()));
  16. static TreeListView()
  17. {
  18. DefaultStyleKeyProperty.OverrideMetadata(typeof(TreeListView), new FrameworkPropertyMetadata(typeof(TreeListView)));
  19. }
  20. /// <summary>
  21. /// 列集合
  22. /// </summary>
  23. public GridViewColumnCollection Columns
  24. {
  25. get { return (GridViewColumnCollection)GetValue(ColumnsProperty); }
  26. set { SetValue(ColumnsProperty, value); }
  27. }
  28. /// <inheritdoc/>
  29. protected override bool IsItemItsOwnContainerOverride(object item)
  30. {
  31. return item is TreeListViewItem;
  32. }
  33. /// <inheritdoc/>
  34. protected override DependencyObject GetContainerForItemOverride()
  35. {
  36. return new TreeListViewItem();
  37. }
  38. }
  39. }