using Muchinfo.MTPClient.Data; using System; using System.Windows.Controls; using System.Windows.Data; namespace Muchinfo.MTPClient.Converters { public class TreeViewLineConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { try { var item = (TreeViewItem)value; ItemsControl ic = ItemsControl.ItemsControlFromItemContainer(item); return ic.ItemContainerGenerator.IndexFromContainer(item) == ic.Items.Count - 1; } catch { return null; } } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new Exception("The method or operation is not implemented."); } } public class NewTreeViewLineConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { try { var item = value as TreeViewItem; if (item == null || item.Header == null) return false; var sysMenuItem = item.Header as SysMenuItem; if (sysMenuItem == null) return false; ////判断是否该项是否无父也无子 if (!item.HasItems && sysMenuItem.ParentItem == null) return true; return false; } catch { return false; } } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return false; } } }