InchingControl.xaml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <UserControl x:Class="TeamAAS_VP.Views.DebugMod.InchingControl"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:prism="http://prismlibrary.com/"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  7. xmlns:vm="clr-namespace:TeamAAS_VP.ViewModels.DebugMod"
  8. xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
  9. xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
  10. xmlns:sys="clr-namespace:System;assembly=mscorlib"
  11. xmlns:enums="clr-namespace:TeamAAS_VP.Enums"
  12. xmlns:localview="clr-namespace:TeamAAS_VP.Views.DebugMod"
  13. xmlns:lex="http://wpflocalizeextension.codeplex.com"
  14. lex:LocalizeDictionary.DesignCulture="zh-CN"
  15. lex:ResxLocalizationProvider.DefaultAssembly="TeamAAS-VP"
  16. lex:ResxLocalizationProvider.DefaultDictionary="Lang"
  17. prism:ViewModelLocator.AutoWireViewModel="True"
  18. mc:Ignorable="d"
  19. d:Background="White"
  20. d:DataContext="{d:DesignInstance Type=vm:InchingControlViewModel}"
  21. FontFamily="{DynamicResource DefaultFont}">
  22. <b:Interaction.Triggers>
  23. <b:EventTrigger EventName="Loaded">
  24. <b:InvokeCommandAction Command="{Binding LoadedCommand}" />
  25. </b:EventTrigger>
  26. </b:Interaction.Triggers>
  27. <Grid Margin="10,0,0,0">
  28. <Grid.RowDefinitions>
  29. <RowDefinition Height="auto" />
  30. <RowDefinition Height="*" />
  31. </Grid.RowDefinitions>
  32. <StackPanel Orientation="Horizontal"
  33. IsEnabled="{Binding IsAllowEdit}">
  34. <Button Content="{materialDesign:PackIcon Kind=AddBold}"
  35. Margin="10"
  36. Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"
  37. Command="{Binding AddCommand}" />
  38. <Button Content="{materialDesign:PackIcon Kind=ContentSaveAll}"
  39. Margin="10"
  40. Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"
  41. Command="{Binding SaveCommand}" />
  42. </StackPanel>
  43. <ItemsControl Grid.Row="1"
  44. ItemsSource="{Binding UserInchingCollection}">
  45. <ItemsControl.ItemsPanel>
  46. <ItemsPanelTemplate>
  47. <WrapPanel Orientation="Horizontal" />
  48. </ItemsPanelTemplate>
  49. </ItemsControl.ItemsPanel>
  50. <ItemsControl.ItemTemplate>
  51. <DataTemplate>
  52. <Button materialDesign:ButtonAssist.CornerRadius="10"
  53. ToolTip="{Binding Name}"
  54. Margin="10"
  55. Command="{Binding DataContext.InchingCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=localview:InchingControl}}"
  56. CommandParameter="{Binding}"
  57. Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=localview:InchingControl}, Path=DataContext}">
  58. <TextBlock Text="{Binding Name}" />
  59. <Button.ContextMenu>
  60. <ContextMenu DataContext="{Binding RelativeSource={RelativeSource Self}, Path=PlacementTarget.Tag}"
  61. IsEnabled="{Binding IsAllowEdit}">
  62. <MenuItem Header="{lex:Loc 移除}"
  63. Command="{Binding RemoveCommand}"
  64. CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.DataContext}"
  65. Icon="{materialDesign:PackIcon Kind=Remove}" />
  66. <Separator />
  67. <MenuItem Header="{lex:Loc 编辑}"
  68. Command="{Binding EditCommand}"
  69. CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.DataContext}"
  70. Icon="{materialDesign:PackIcon Kind=Edit}" />
  71. </ContextMenu>
  72. </Button.ContextMenu>
  73. <Button.Style>
  74. <Style TargetType="Button"
  75. BasedOn="{StaticResource MaterialDesignRaisedButton}">
  76. <Style.Triggers>
  77. <DataTrigger Binding="{Binding State}" Value="True">
  78. <Setter Property="Background"
  79. Value="Green" />
  80. </DataTrigger>
  81. <DataTrigger Binding="{Binding State}"
  82. Value="False">
  83. <Setter Property="Background"
  84. Value="DarkRed" />
  85. </DataTrigger>
  86. </Style.Triggers>
  87. </Style>
  88. </Button.Style>
  89. </Button>
  90. </DataTemplate>
  91. </ItemsControl.ItemTemplate>
  92. </ItemsControl>
  93. </Grid>
  94. </UserControl>