TreeViewLineConverter.cs 772 B

123456789101112131415161718192021
  1. using System;
  2. using System.Windows.Controls;
  3. using System.Windows.Data;
  4. namespace Muchinfo.PC.Common.Converter
  5. {
  6. public class TreeViewLineConverter : IValueConverter
  7. {
  8. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  9. {
  10. var item = (TreeViewItem)value;
  11. ItemsControl ic = ItemsControl.ItemsControlFromItemContainer(item);
  12. return ic.ItemContainerGenerator.IndexFromContainer(item) == ic.Items.Count - 1;
  13. }
  14. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  15. {
  16. throw new Exception("The method or operation is not implemented.");
  17. }
  18. }
  19. }