JD2022-TU1/main/tools/modules/JD.Rosetta.Module.OptionsGrid/ExportOptionsPropertyGrid.xaml.cs

59 lines
2.7 KiB
C#

using System.Windows;
using System.Windows.Controls;
using ActiproSoftware.Windows.Controls.Grids;
using ActiproSoftware.Windows.Controls.Grids.PropertyData;
namespace JD.Rosetta.Module.OptionsGrid
{
/// <summary>
/// Interaction logic for ExportOptionsPropertyGrid.xaml
/// </summary>
public partial class ExportOptionsPropertyGrid : UserControl
{
public ExportOptionsPropertyGrid()
{
InitializeComponent();
}
#region Dependency properties
public static readonly DependencyProperty DataObjectProperty = DependencyProperty.Register("DataObject",
typeof(object),
typeof(ExportOptionsPropertyGrid),
new PropertyMetadata(default(object), DataObjectProperty_PropertyChangedCallback));
// Need to do this rather than a binding to get it working for some reason
private static void DataObjectProperty_PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var view = (ExportOptionsPropertyGrid)d;
view.OptionsGrid.DataObject = e.NewValue as object;
}
public object DataObject
{
get => (object) GetValue(DataObjectProperty);
set => SetValue(DataObjectProperty, value);
}
public static readonly DependencyProperty PropertyFactoryProperty = DependencyProperty.Register("PropertyFactory",
typeof(IDataFactory),
typeof(ExportOptionsPropertyGrid),
new PropertyMetadata(null, PropertyFactoryProperty_PropertyChangedCallback));
// Need to do this rather than a binding to get it working for some reason
private static void PropertyFactoryProperty_PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var view = (ExportOptionsPropertyGrid)d;
view.OptionsGrid.DataFactory = e.NewValue as IDataFactory;
}
public IDataFactory PropertyFactory
{
get => (IDataFactory) GetValue(PropertyFactoryProperty);
set => SetValue(PropertyFactoryProperty, value);
}
#endregion
}
}