Files
laatzen/Common/TestUI/DynamicGrid.xaml.cs
T

43 lines
1.3 KiB
C#

namespace TestUI
{
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using TestUI.ViewModels;
public partial class DynamicGrid : Grid
{
public DynamicGrid()
{
this.InitializeComponent();
}
public ObservableCollection<ItemsRowVM> ItemsSource
{
get => this.GetValue(ItemsSourceProperty) as ObservableCollection<ItemsRowVM>;
set => this.SetValue(ItemsSourceProperty, value);
}
}
public partial class DynamicGrid
{
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(
name: nameof(ItemsSource),
propertyType: typeof(ObservableCollection<ItemsRowVM>),
ownerType: typeof(DynamicGrid),
typeMetadata: new FrameworkPropertyMetadata(
new ObservableCollection<ItemsRowVM>(),
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
new PropertyChangedCallback(UpdateDynamicGrid)));
private static void UpdateDynamicGrid(DependencyObject sender, DependencyPropertyChangedEventArgs args)
{
if (sender is DynamicGrid dynamicGrid && args.NewValue is ObservableCollection<ItemsRowVM> rows)
{
}
}
}
}