Refactor ProductsDisplay
This commit is contained in:
parent
c01e1c3e4b
commit
dfedb23efd
9 changed files with 151 additions and 386 deletions
|
|
@ -174,13 +174,12 @@ namespace LibationAvalonia.Views
|
|||
|
||||
public void ProductsDisplay_Initialized1(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is ProductsDisplay products)
|
||||
_viewModel.ProductsDisplay.RegisterCollectionChanged(products);
|
||||
|
||||
}
|
||||
|
||||
private void MainWindow_LibraryLoaded(object sender, List<LibraryBook> dbBooks)
|
||||
private async void MainWindow_LibraryLoaded(object sender, List<LibraryBook> dbBooks)
|
||||
{
|
||||
_viewModel.ProductsDisplay.InitialDisplay(dbBooks);
|
||||
await _viewModel.ProductsDisplay.DisplayBooks(dbBooks);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
|
|
|
|||
|
|
@ -20,16 +20,25 @@
|
|||
CanUserReorderColumns="True">
|
||||
|
||||
<DataGrid.Columns>
|
||||
|
||||
<controls:DataGridCheckBoxColumnExt
|
||||
PropertyChanged="RemoveColumn_PropertyChanged"
|
||||
IsVisible="{Binding RemoveColumnVisivle}"
|
||||
Header="Remove"
|
||||
IsThreeState="True"
|
||||
IsReadOnly="False"
|
||||
|
||||
<DataGridTemplateColumn
|
||||
CanUserSort="True"
|
||||
Binding="{Binding Remove, Mode=TwoWay}"
|
||||
Width="70" SortMemberPath="Remove" />
|
||||
IsVisible="{Binding RemoveColumnVisivle}"
|
||||
PropertyChanged="RemoveColumn_PropertyChanged"
|
||||
Header="Remove"
|
||||
IsReadOnly="False"
|
||||
SortMemberPath="Remove"
|
||||
Width="75">
|
||||
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox
|
||||
HorizontalAlignment="Center"
|
||||
IsThreeState="True"
|
||||
IsChecked="{Binding Remove, Mode=TwoWay}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn CanUserSort="True" Width="75" Header="Liberate" SortMemberPath="Liberate">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
|
|
|
|||
|
|
@ -27,20 +27,25 @@ namespace LibationAvalonia.Views
|
|||
if (Design.IsDesignMode)
|
||||
{
|
||||
using var context = DbContexts.GetContext();
|
||||
List<GridEntry> sampleEntries = new()
|
||||
List<LibraryBook> sampleEntries = new()
|
||||
{
|
||||
new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B00DCD0OXU")),
|
||||
new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017V4IM1G")),
|
||||
new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017V4IWVG")),
|
||||
new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017V4JA2Q")),
|
||||
new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017V4NUPO")),
|
||||
new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017V4NMX4")),
|
||||
new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017V4NOZ0")),
|
||||
new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017WJ5ZK6")),
|
||||
//context.GetLibraryBook_Flat_NoTracking("B00DCD0OXU"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017V4IM1G"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017V4IWVG"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017V4JA2Q"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017V4NUPO"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017V4NMX4"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017V4NOZ0"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017WJ5ZK6")
|
||||
};
|
||||
DataContext = new ProductsDisplayViewModel(sampleEntries);
|
||||
|
||||
var pdvm = new ProductsDisplayViewModel();
|
||||
pdvm.DisplayBooks(sampleEntries);
|
||||
DataContext = pdvm;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Configure_ColumnCustomization();
|
||||
|
||||
foreach (var column in productsGrid.Columns)
|
||||
|
|
@ -51,7 +56,7 @@ namespace LibationAvalonia.Views
|
|||
|
||||
private void ProductsGrid_Sorting(object sender, DataGridColumnEventArgs e)
|
||||
{
|
||||
_viewModel.Sort(e.Column);
|
||||
|
||||
}
|
||||
|
||||
private void RemoveColumn_PropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue