瀏覽代碼

avalonia: Added title to SelectionViewModel when using popup mode.

Kenric Nugteren 3 月之前
父節點
當前提交
6ce0c70fa5

+ 18 - 3
PRS.Avalonia/PRS.Avalonia/Components/SelectionView/SelectionView.axaml

@@ -4,18 +4,33 @@
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
              x:Class="PRS.Avalonia.Components.SelectionView"
+			 xmlns:converters="using:InABox.Avalonia.Converters"
 			 xmlns:components="using:InABox.Avalonia.Components"
 			 xmlns:prsComponents="using:PRS.Avalonia.Components"
 			 x:DataType="prsComponents:SelectionViewModel">
+	<UserControl.Resources>
+		<converters:BooleanMatcher x:Key="BooleanAnd" Value="True" Type="All"/>
+	</UserControl.Resources>
 	<Grid>
 		<Grid.RowDefinitions>
+			<RowDefinition Height="Auto"/>
 			<RowDefinition Height="Auto"/>
 			<RowDefinition Height="*"/>
 			<RowDefinition Height="Auto"/>
 		</Grid.RowDefinitions>
-		<components:ButtonStrip Name="Filters" Grid.Row="0" ItemsSource="{Binding FilterButtons}" SelectionChanged="Filters_OnSelectionChanged"
+		<Label Grid.Row="0" Content="{Binding SelectionTitle}"
+			   FontWeight="{StaticResource PrsFontWeightBold}"
+			   FontSize="{StaticResource PrsFontSizeLarge}">
+			<Label.IsVisible>
+				<MultiBinding Converter="{StaticResource BooleanAnd}">
+					<Binding Path="IsPopup"/>
+					<Binding Path="SelectionTitle" Converter="{x:Static StringConverters.IsNotNullOrEmpty}"/>
+				</MultiBinding>
+			</Label.IsVisible>
+		</Label>
+		<components:ButtonStrip Name="Filters" Grid.Row="1" ItemsSource="{Binding FilterButtons}" SelectionChanged="Filters_OnSelectionChanged"
 								SelectedItem="{Binding SelectedFilter}"/>
-		<components:AvaloniaDataGrid Name="Grid" Grid.Row="1"
+		<components:AvaloniaDataGrid Name="Grid" Grid.Row="2"
 									 ItemsSource="{Binding ItemsSource}"
 									 RefreshRequested="Grid_OnRefreshRequested"
 									 SelectionChanged="Grid_OnSelectionChanged"
@@ -23,7 +38,7 @@
 									 CanSearch="{Binding CanSearch}"
 									 RefreshVisible="{Binding CanRefresh}"
 									 LastUpdated="{Binding LastUpdated}"/>
-		<ScrollViewer Grid.Row="2"
+		<ScrollViewer Grid.Row="3"
 					  HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
 			<ItemsControl ItemsSource="{Binding Buttons}">
 				<ItemsControl.ItemsPanel>

+ 8 - 2
PRS.Avalonia/PRS.Avalonia/Components/SelectionView/SelectionViewModel.cs

@@ -1,4 +1,5 @@
-using Avalonia.Media;
+using Avalonia.Layout;
+using Avalonia.Media;
 using CommunityToolkit.Mvvm.ComponentModel;
 using CommunityToolkit.Mvvm.Input;
 using InABox.Avalonia;
@@ -32,7 +33,7 @@ public enum SelectionPageMode
     Immediate
 }
 
-public partial class SelectionViewModel : PopupViewModel<object?[]>, IModuleViewModel, IDualFunctionViewModel
+public partial class SelectionViewModel : PopupViewModel<object?[]>, IModuleViewModel, IDualFunctionViewModel, IAlignedPopup
 {
     public string Title => SelectionTitle;
 
@@ -49,6 +50,11 @@ public partial class SelectionViewModel : PopupViewModel<object?[]>, IModuleView
     public AvaloniaDataGridColumns Columns { get; } = new();
     public bool IsPopup { get; set; }
 
+    public HorizontalAlignment HorizontalAlignment { get; set; } = HorizontalAlignment.Stretch;
+
+    public VerticalAlignment VerticalAlignment { get; set; } = VerticalAlignment.Stretch;
+
+
     [ObservableProperty]
     private IEnumerable? _itemsSource;