コード例 #1
0
ファイル: ItemsControl.cs プロジェクト: thrmotta/Imagin.NET
 /// <summary>
 ///
 /// </summary>
 /// <param name="ToEvaluate"></param>
 public static void ClearSelection(this ItemsControl ToEvaluate)
 {
     if (ToEvaluate is ListBox)
     {
         (ToEvaluate as ListBox).SelectedItems.Clear();
     }
     else if (ToEvaluate is DataGrid)
     {
         (ToEvaluate as DataGrid).SelectedItems.Clear();
     }
     else if (ToEvaluate is TreeView)
     {
         var TreeView = ToEvaluate.As <TreeView>();
         var Item     = TreeView.ItemContainerGenerator.ContainerFromItem(TreeView.SelectedItem);
         if (Item != null)
         {
             Item.As <TreeViewItem>().IsSelected = false;
         }
     }
     else if (ToEvaluate is TreeView)
     {
         ToEvaluate.As <TreeView>().SelectNone();
     }
 }