예제 #1
0
        public static void SetRemoveCommand(DependencyObject parent, string dataGridName, ICommand command)
        {
            DataGrid dataGrid = VisualTreeFinder.FindChild <DataGrid>(parent, dataGridName);

            if (dataGrid == null)
            {
                Debug.WriteLine("SetRemoveCommand: dataGrid is not found name=" + dataGridName);
                return;
            }
            SetRemoveCommand(dataGrid, command);
        }
        public static DataGrid GetParentDatagrid(UIElement element)
        {
            UIElement childElement;      //element from which to start the tree navigation, looking for a Datagrid parent

            if (element is ComboBoxItem) //since ComboBoxItem.Parent is null, we must pass through ItemsPresenter in order to get the parent ComboBox
            {
                ItemsPresenter parentItemsPresenter = VisualTreeFinder.FindParentControl <ItemsPresenter>((element as ComboBoxItem));
                ComboBox       combobox             = parentItemsPresenter.TemplatedParent as ComboBox;
                childElement = combobox;
            }
            else
            {
                childElement = element;
            }

            DataGrid parentDatagrid = VisualTreeFinder.FindParentControl <DataGrid>(childElement); //let's see if the new focused element is inside a datagrid

            return(parentDatagrid);
        }
예제 #3
0
 private static void GetTargetElement(TextBox sender, out DependencyObject element, out DependencyProperty dp)
 {
     element = null;
     dp      = null;
     if (sender is TextBox)
     {
         if ((sender.Tag as string) == EDOConstants.TAG_UNDOABLE)
         {
             element = sender;
             dp      = TextBox.TextProperty;
         }
         else
         {
             ComboBox combo = VisualTreeFinder.FindParentControl <ComboBox>(sender);
             if (combo != null && (combo.Tag as string) == EDOConstants.TAG_UNDOABLE)
             {
                 element = combo;
                 dp      = ComboBox.TextProperty;
             }
         }
     }
 }
예제 #4
0
 public static DataGrid FindDataGrid(DependencyObject parent, string name)
 {
     return(VisualTreeFinder.FindChild <DataGrid>(parent, name));
 }