private static void ConfigPathPropertyChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs arg) { if (sender != null && sender is UCDataGrid) { UCDataGrid dg = sender as UCDataGrid; if (dg.ElementPath == null || dg.ElementPath == string.Empty) { return; } ///加载配置的信息。 } }
/// <summary> /// ElementPath属性值发生变化。 /// </summary> /// <param name="sender"></param> /// <param name="arg"></param> private static void ElementPathPropertyChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs arg) { if (sender != null && sender is UCDataGrid) { UCDataGrid dg = sender as UCDataGrid; if (dg != null) { dg.Columns.Clear(); MyXMLColumnsHelper xmlHelper = new MyXMLColumnsHelper(dg.ConfigPath, dg.ElementPath); if (xmlHelper.ColumnsList != null) { //ICollectionView view = CollectionViewSource.GetDefaultView(arg.NewValue); ICollectionView view = CollectionViewSource.GetDefaultView(xmlHelper.ColumnsList); if (view != null) { dg.CreateColumns(dg, view); } } } } }