通过 listboxitem 查找属于listbox第几条数据

 public override System.Windows.Style SelectStyle(object item, System.Windows.DependencyObject container)
        {
            if (ContainerStyle1 == null)
                return null;
            TCheckListBoxItem citem = container as TCheckListBoxItem;
            TCheckListBox listView = ItemsControl.ItemsControlFromItemContainer(container) as TCheckListBox;
            int index =listView.ItemContainerGenerator.IndexFromContainer(container);
            if (index % 2 == 0)
            {
                citem.IsOddIndex = true;
                //IsOddIndex.Value = true;
            }
            else
            {
                citem.IsOddIndex = false;
               // IsOddIndex.Value = false;
            }
            return ContainerStyle1;
        }

 

posted @ 2016-11-16 17:56  莫欺  阅读(1170)  评论(0)    收藏  举报