Notes/Notes.UI/Views/AllNotesView.axaml

51 lines
2.5 KiB
Plaintext
Raw Normal View History

2023-12-06 11:03:26 +08:00
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Notes.Views"
xmlns:viewModels="clr-namespace:Notes.ViewModels;assembly=Notes.Data"
x:DataType="viewModels:AllNotesViewModel">
<Design.PreviewWith>
<controls:AllNotesView />
</Design.PreviewWith>
<Style Selector="controls|AllNotesView">
<!-- Set Defaults -->
<Setter Property="Template">
<ControlTemplate>
<DockPanel Margin="20">
<DockPanel DockPanel.Dock="Top">
<TextBlock FontWeight="600" FontSize="20" Margin="0 5">笔记列表:</TextBlock>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button Command="{Binding NewNoteCommand}">新建</Button>
<Button
Command="{Binding DeleteNoteCommand}">删除
</Button>
<Button Command="{Binding OpenAboutCommand}">关于</Button>
</StackPanel>
</DockPanel>
<DockPanel>
<ListBox Name="listNotes"
SelectionMode="Multiple"
ItemsSource="{Binding Notes}">
<ListBox.ItemTemplate>
<DataTemplate>
<DockPanel>
<Button Content="打开"
Command="{Binding $parent[ListBox].((viewModels:AllNotesViewModel)DataContext).OpenNoteCommand}"
CommandParameter="{Binding}"
DockPanel.Dock="Left"
Margin="0"
Padding="3" />
<TextBlock Text="{Binding ShortName}" />
<TextBlock Margin="5 0" FontWeight="Bold"
Text="{Binding Date}" />
</DockPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
</DockPanel>
</ControlTemplate>
</Setter>
</Style>
</Styles>