diff --git a/Aurora/Design/Components/DataGrid/DataGrid.xaml b/Aurora/Design/Components/DataGrid/DataGrid.xaml
index d6ae78c..3ec3f45 100644
--- a/Aurora/Design/Components/DataGrid/DataGrid.xaml
+++ b/Aurora/Design/Components/DataGrid/DataGrid.xaml
@@ -87,7 +87,7 @@
-
+
_internalItems;
-
- private Dictionary _sortingOrders;
-
- #endregion Fields
-
- #region Constructor
-
- public DataGrid() : this(ListViewCachingStrategy.RetainElement)
- {
- }
-
- public DataGrid(ListViewCachingStrategy cachingStrategy)
- {
- InitializeComponent();
- BackgroundColor = Color.Transparent;
-
- _sortingOrders = new Dictionary();
-
- DataList.ItemTemplate = new DataGridRowTemplateSelector();
-
- DataList.ItemSelected += (s, e) =>
- {
- if (SelectionEnabled)
- {
- SelectedItem = DataList.SelectedItem;
- }
- else
- {
- DataList.SelectedItem = null;
- }
-
- ItemSelected?.Invoke(this, e);
- };
-
- DataList.Refreshing += (s, e) =>
- {
- Refreshing?.Invoke(this, e);
- };
-
- DataList.SetBinding(ListView.RowHeightProperty, new Binding("RowHeight", source: this));
- }
- #endregion Constructor
-
- #region Public Fields
public event EventHandler Refreshing;
public event EventHandler ItemSelected;
- #endregion Public Fields
-
#region Bindable properties
public static readonly BindableProperty ActiveRowColorProperty =
- BindableProperty.Create(
- nameof(ActiveRowColor),
- typeof(Color),
- typeof(DataGrid),
- Color.FromRgb(128, 144, 160),
- coerceValue: (bindable, value) =>
+ BindableProperty.Create(nameof(ActiveRowColor), typeof(Color), typeof(DataGrid), Color.FromRgb(128, 144, 160),
+ coerceValue: (b, v) =>
{
- if (!(bindable as DataGrid).SelectionEnabled)
+ if (!(b as DataGrid).SelectionEnabled)
throw new InvalidOperationException("Datagrid must be SelectionEnabled=true to set ActiveRowColor");
- return value;
+ return v;
});
public static readonly BindableProperty HeaderBackgroundProperty =
- BindableProperty.Create(
- nameof(HeaderBackground),
- typeof(Color),
- typeof(DataGrid),
- Color.White,
- propertyChanged: (bindable, oldValue, newValue) =>
+ BindableProperty.Create(nameof(HeaderBackground), typeof(Color), typeof(DataGrid), Color.White,
+ propertyChanged: (b, o, n) =>
{
- var self = bindable as DataGrid;
+ var self = b as DataGrid;
if (self._headerView != null && !self.HeaderBordersVisible)
- self._headerView.BackgroundColor = (Color)newValue;
+ self._headerView.BackgroundColor = (Color)n;
});
public static readonly BindableProperty BorderColorProperty =
- BindableProperty.Create(
- nameof(BorderColor),
- typeof(Color),
- typeof(DataGrid),
- Color.Black,
- propertyChanged: (bindable, oldValue, newValue) =>
+ BindableProperty.Create(nameof(BorderColor), typeof(Color), typeof(DataGrid), Color.Black,
+ propertyChanged: (b, o, n) =>
{
- var self = bindable as DataGrid;
+ var self = b as DataGrid;
if (self.HeaderBordersVisible)
- self._headerView.BackgroundColor = (Color)newValue;
+ self._headerView.BackgroundColor = (Color)n;
if (self.Columns != null && self.ItemsSource != null)
self.Reload();
});
public static readonly BindableProperty RowsBackgroundColorPaletteProperty =
- BindableProperty.Create(nameof(RowsBackgroundColorPalette),
- typeof(IColorProvider),
- typeof(DataGrid),
- new PaletteCollection { default(Color) },
- propertyChanged: (bindable, oldValue, newValue) =>
+ BindableProperty.Create(nameof(RowsBackgroundColorPalette), typeof(IColorProvider), typeof(DataGrid), new PaletteCollection { default(Color) },
+ propertyChanged: (b, o, n) =>
{
- var self = bindable as DataGrid;
+ var self = b as DataGrid;
if (self.Columns != null && self.ItemsSource != null)
self.Reload();
});
public static readonly BindableProperty RowsTextColorPaletteProperty =
- BindableProperty.Create(
- nameof(RowsTextColorPalette),
- typeof(IColorProvider),
- typeof(DataGrid),
- new PaletteCollection { Color.Black },
- propertyChanged: (bindable, oldValue, newValue) =>
+ BindableProperty.Create(nameof(RowsTextColorPalette), typeof(IColorProvider), typeof(DataGrid), new PaletteCollection { Color.Black },
+ propertyChanged: (b, o, n) =>
{
- var self = bindable as DataGrid;
+ var self = b as DataGrid;
if (self.Columns != null && self.ItemsSource != null)
self.Reload();
});
public static readonly BindableProperty ColumnsProperty =
- BindableProperty.Create(
- nameof(Columns),
- typeof(ColumnCollection),
- typeof(DataGrid),
- propertyChanged: (bindable, oldValue, newValue) =>
- {
- (bindable as DataGrid).InitHeaderView();
- },
- defaultValueCreator: bindable => { return new ColumnCollection(); }
+ BindableProperty.Create(nameof(Columns), typeof(ColumnCollection), typeof(DataGrid),
+ propertyChanged: (b, o, n) => (b as DataGrid).InitHeaderView(),
+ defaultValueCreator: b => { return new ColumnCollection(); }
);
- public static BindableProperty ItemsSourceProperty =
- BindableProperty.Create(
- propertyName: nameof(ItemsSource),
- returnType: typeof(IEnumerable),
- declaringType: typeof(DataGrid),
- defaultBindingMode: BindingMode.TwoWay,
- propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty ItemsSourceProperty =
+ BindableProperty.Create(nameof(ItemsSource), typeof(IEnumerable), typeof(DataGrid), null,
+ propertyChanged: (b, o, n) =>
{
- DataGrid self = bindable as DataGrid;
+ DataGrid self = b as DataGrid;
//ObservableCollection Tracking
- if (oldValue != null && oldValue is INotifyCollectionChanged)
- {
- (oldValue as INotifyCollectionChanged).CollectionChanged -= self.HandleItemsSourceCollectionChanged;
- }
+ if (o != null && o is INotifyCollectionChanged)
+ (o as INotifyCollectionChanged).CollectionChanged -= self.HandleItemsSourceCollectionChanged;
- if (newValue != null && newValue is INotifyCollectionChanged)
+ if (n != null)
{
- (newValue as INotifyCollectionChanged).CollectionChanged += self.HandleItemsSourceCollectionChanged;
+ if (n is INotifyCollectionChanged)
+ (n as INotifyCollectionChanged).CollectionChanged += self.HandleItemsSourceCollectionChanged;
- self.InternalItems = new ObservableCollection
\ No newline at end of file