Skip to content

Commit b78dba8

Browse files
authored
fix: replace ListBox with Button-based ItemsControl for navigation (#22)
- Add x:Name=MainWin to Window for ElementName binding - Replace ListBox + TextBlock with ItemsControl + Button - Each Button binds to MainWindow.NavigateCommand with NavItem as parameter
1 parent 4ca0bd2 commit b78dba8

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

src/Views/MainWindow.axaml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
1-
<Window xmlns="https://github.com/avaloniaui"
1+
<Window xmlns="https://github.com/avaloniaui"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:vm="using:GeneralUpdate.Tools.ViewModels"
44
x:Class="GeneralUpdate.Tools.Views.MainWindow"
5+
x:Name="MainWin"
56
x:DataType="vm:MainWindowViewModel"
6-
Title="GeneralUpdate Tools v12" Width="960" Height="640" MinWidth="780" MinHeight="540"
7+
Title="GeneralUpdate Tools" Width="960" Height="640" MinWidth="780" MinHeight="540"
78
WindowStartupLocation="CenterScreen">
89
<DockPanel>
910
<Border DockPanel.Dock="Left" Width="200" Background="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}">
1011
<Grid RowDefinitions="Auto,*">
1112
<Border Grid.Row="0" Padding="18,20,18,12">
1213
<TextBlock Text="GeneralUpdate Tools" FontSize="16" FontWeight="Bold"/>
1314
</Border>
14-
<ListBox Grid.Row="1" ItemsSource="{Binding NavItems}" Background="Transparent" BorderThickness="0">
15-
<ListBox.ItemTemplate>
15+
<ItemsControl Grid.Row="1" ItemsSource="{Binding NavItems}">
16+
<ItemsControl.ItemTemplate>
1617
<DataTemplate x:DataType="vm:NavItem">
17-
<Border Padding="18,10" Background="Transparent" CornerRadius="0,8,8,0">
18-
<TextBlock Text="{Binding Title}" FontSize="13"/>
19-
</Border>
18+
<Button Content="{Binding Title}"
19+
Command="{Binding ElementName=MainWin, Path=DataContext.NavigateCommand}"
20+
CommandParameter="{Binding}"
21+
HorizontalAlignment="Stretch"
22+
HorizontalContentAlignment="Left"
23+
Padding="18,10"
24+
Margin="0"
25+
Background="Transparent"
26+
BorderThickness="0"
27+
FontSize="13"/>
2028
</DataTemplate>
21-
</ListBox.ItemTemplate>
22-
</ListBox>
29+
</ItemsControl.ItemTemplate>
30+
</ItemsControl>
2331
</Grid>
2432
</Border>
2533
<ContentControl Content="{Binding CurrentPage}"/>

0 commit comments

Comments
 (0)