NavigationPageMvvmPage.xaml 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <UserControl xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:pages="using:ControlCatalog.Pages"
  4. x:Class="ControlCatalog.Pages.NavigationPageMvvmPage"
  5. x:DataType="pages:NavigationPageMvvmShellViewModel">
  6. <DockPanel>
  7. <ScrollViewer DockPanel.Dock="Right" Width="300">
  8. <StackPanel Margin="12" Spacing="12">
  9. <TextBlock Text="MVVM Pattern"
  10. FontSize="16"
  11. FontWeight="SemiBold"
  12. Foreground="{DynamicResource SystemControlHighlightAccentBrush}" />
  13. <TextBlock TextWrapping="Wrap"
  14. FontSize="12"
  15. Opacity="0.75"
  16. Text="This sample keeps NavigationPage in the view, sends commands from view models, routes push or pop operations through ISampleNavigationService, and resolves pages in a separate SamplePageFactory." />
  17. <Separator />
  18. <TextBlock Text="Selected Project"
  19. FontSize="13"
  20. FontWeight="SemiBold" />
  21. <ListBox ItemsSource="{Binding Projects}"
  22. SelectedItem="{Binding SelectedProject, Mode=TwoWay}"
  23. MaxHeight="180">
  24. <ListBox.ItemTemplate>
  25. <DataTemplate x:DataType="pages:ProjectCardViewModel">
  26. <StackPanel Margin="0,2" Spacing="2">
  27. <TextBlock Text="{Binding Name}"
  28. FontWeight="SemiBold" />
  29. <TextBlock Text="{Binding Owner}"
  30. FontSize="11"
  31. Opacity="0.65" />
  32. </StackPanel>
  33. </DataTemplate>
  34. </ListBox.ItemTemplate>
  35. </ListBox>
  36. <Button Content="Open Selected Project"
  37. Command="{Binding OpenSelectedProjectCommand}" />
  38. <Button Content="Back"
  39. Command="{Binding GoBackCommand}" />
  40. <Button Content="Pop To Root"
  41. Command="{Binding PopToRootCommand}" />
  42. <Separator />
  43. <TextBlock Text="Navigation State"
  44. FontSize="13"
  45. FontWeight="SemiBold" />
  46. <TextBlock Text="{Binding CurrentPageHeader, StringFormat=Current page: {0}}"
  47. Opacity="0.75" />
  48. <TextBlock Text="{Binding NavigationDepth, StringFormat=Stack depth: {0}}"
  49. Opacity="0.75" />
  50. <TextBlock Text="{Binding LastAction, StringFormat=Last action: {0}}"
  51. Opacity="0.75"
  52. TextWrapping="Wrap" />
  53. <Separator />
  54. <TextBlock Text="Selected Details"
  55. FontSize="13"
  56. FontWeight="SemiBold" />
  57. <TextBlock Text="{Binding SelectedProject.Status, StringFormat=Status: {0}}"
  58. Opacity="0.75" />
  59. <TextBlock Text="{Binding SelectedProject.NextMilestone, StringFormat=Next milestone: {0}}"
  60. Opacity="0.75"
  61. TextWrapping="Wrap" />
  62. </StackPanel>
  63. </ScrollViewer>
  64. <Border DockPanel.Dock="Right"
  65. Width="1"
  66. Background="{DynamicResource SystemControlForegroundBaseMediumLowBrush}" />
  67. <Border Margin="12"
  68. BorderBrush="{DynamicResource SystemControlForegroundBaseMediumLowBrush}"
  69. BorderThickness="1"
  70. CornerRadius="6"
  71. ClipToBounds="True">
  72. <NavigationPage x:Name="DemoNav" />
  73. </Border>
  74. </DockPanel>
  75. </UserControl>