Refactoring history page

This commit is contained in:
Selim Mustafaev 2023-12-30 23:18:14 +03:00
parent 4eb96be9dd
commit 6259d182e4
5 changed files with 120 additions and 5 deletions

View File

@ -3,7 +3,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="clr-namespace:AutoCat.Pages" xmlns:pages="clr-namespace:AutoCat.Pages"
xmlns:utils="using:AutoCat.Utils" xmlns:utils="using:AutoCat.Utils"
xmlns:vm="using:AutoCat.ViewModels" xmlns:vm="using:AutoCat.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
@ -22,8 +21,9 @@
<Grid ColumnDefinitions="300, Auto, *"> <Grid ColumnDefinitions="300, Auto, *">
<ListBox ItemsSource="{Binding Vehicles}" <ListBox ItemsSource="{Binding Vehicles}"
ItemTemplate="{StaticResource VehicleCell}"/> ItemTemplate="{StaticResource VehicleCell}"
Name="VehiclesList"/>
<GridSplitter Grid.Column="1" ResizeDirection="Columns"/> <GridSplitter Grid.Column="1" ResizeDirection="Columns"/>
<pages:ReportPage Grid.Column="2"/> <pages:ReportPage Grid.Column="2" Vehicle="{Binding ElementName=VehiclesList, Path=SelectedItem, Mode=OneWay}"/>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -2,7 +2,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="clr-namespace:AutoCat.Pages"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AutoCat.Pages.ReportPage"> x:Class="AutoCat.Pages.ReportPage"
Welcome to Avalonia! x:DataType="pages:ReportPage"
x:CompileBindings="True">
<TextBlock Text="{Binding Vehicle.Number}"/>
</UserControl> </UserControl>

View File

@ -1,3 +1,6 @@
using System;
using System.ComponentModel;
using AutoCatCore.Model;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
@ -6,8 +9,26 @@ namespace AutoCat.Pages;
public partial class ReportPage : UserControl public partial class ReportPage : UserControl
{ {
#region Dependency properties
public static readonly StyledProperty<Vehicle> VehicleProperty =
AvaloniaProperty.Register<ReportPage, Vehicle>(nameof(Vehicle));
#endregion
#region Properties
public Vehicle Vehicle
{
get => (Vehicle)GetValue(VehicleProperty);
set => SetValue(VehicleProperty, value);
}
#endregion
public ReportPage() public ReportPage()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this;
} }
} }

View File

@ -0,0 +1,30 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="clr-namespace:AutoCat.Pages"
xmlns:views="clr-namespace:AutoCat.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AutoCat.Views.MasterDetailView"
x:DataType="views:MasterDetailView"
x:CompileBindings="True">
<Grid ColumnDefinitions="300, Auto, *">
<ListBox ItemsSource="{Binding ItemsSource}"
ItemTemplate="{Binding ItemTemplate}"
Name="VehiclesList"/>
<GridSplitter Grid.Column="1" ResizeDirection="Columns"/>
<!--
<pages:ReportPage Grid.Column="2" Vehicle="{Binding ElementName=VehiclesList, Path=SelectedItem, Mode=OneWay}"/>
-->
<ContentControl Grid.Column="2" Name="DetailControl">
<ContentControl.Styles>
<Style Selector="ContentControl#DetailControl">
<Style.Setters>
<Setter Property="Template" Value="{Binding DetailTemplate}"/>
</Style.Setters>
</Style>
</ContentControl.Styles>
</ContentControl>
</Grid>
</UserControl>

View File

@ -0,0 +1,60 @@
using System.Collections;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Avalonia.Markup.Xaml;
namespace AutoCat.Views;
public partial class MasterDetailView : UserControl
{
#region Dependency properties
public static readonly StyledProperty<IDataTemplate?> ItemTemplateProperty =
AvaloniaProperty.Register<MasterDetailView, IDataTemplate?>(nameof(ItemTemplate));
public static readonly StyledProperty<IDataTemplate?> DetailTemplateProperty =
AvaloniaProperty.Register<MasterDetailView, IDataTemplate?>(nameof(DetailTemplate));
public static readonly StyledProperty<IDataTemplate?> EmptyDetailTemplateProperty =
AvaloniaProperty.Register<MasterDetailView, IDataTemplate?>(nameof(EmptyDetailTemplate));
public static readonly StyledProperty<IEnumerable?> ItemsSourceProperty =
AvaloniaProperty.Register<MasterDetailView, IEnumerable?>(nameof(ItemsSource));
#endregion
#region Properties
public IDataTemplate? ItemTemplate
{
get => GetValue(ItemTemplateProperty);
set => SetValue(ItemTemplateProperty, value);
}
public IDataTemplate? DetailTemplate
{
get => GetValue(DetailTemplateProperty);
set => SetValue(DetailTemplateProperty, value);
}
public IDataTemplate? EmptyDetailTemplate
{
get => GetValue(EmptyDetailTemplateProperty);
set => SetValue(EmptyDetailTemplateProperty, value);
}
public IEnumerable? ItemsSource
{
get => GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}
#endregion
public MasterDetailView()
{
InitializeComponent();
DataContext = this;
}
}