PartCatalogView.xaml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <UserControl x:Class="LocalhostMES.Views.Tabs.PartCatalogView"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:prism="http://prismlibrary.com/"
  7. xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
  8. prism:ViewModelLocator.AutoWireViewModel="True"
  9. mc:Ignorable="d"
  10. d:DesignHeight="480"
  11. d:DesignWidth="780">
  12. <b:Interaction.Triggers>
  13. <b:EventTrigger EventName="Loaded">
  14. <b:InvokeCommandAction Command="{Binding LoadedCommand}" />
  15. </b:EventTrigger>
  16. </b:Interaction.Triggers>
  17. <Grid Margin="10">
  18. <Grid.RowDefinitions>
  19. <RowDefinition Height="Auto" />
  20. <RowDefinition Height="Auto" />
  21. <RowDefinition Height="*" />
  22. </Grid.RowDefinitions>
  23. <TextBlock Grid.Row="0"
  24. Text="零件管理"
  25. FontSize="20"
  26. FontWeight="Bold"
  27. HorizontalAlignment="Center"
  28. Margin="0,0,0,16" />
  29. <GroupBox Grid.Row="1"
  30. Header="添加/编辑零件"
  31. Margin="0,0,0,10">
  32. <Grid Margin="10">
  33. <Grid.ColumnDefinitions>
  34. <ColumnDefinition Width="Auto" />
  35. <ColumnDefinition Width="*" />
  36. </Grid.ColumnDefinitions>
  37. <Grid.RowDefinitions>
  38. <RowDefinition Height="Auto" />
  39. <RowDefinition Height="Auto" />
  40. <RowDefinition Height="Auto" />
  41. </Grid.RowDefinitions>
  42. <TextBlock Grid.Row="0"
  43. Grid.Column="0"
  44. Text="名称:"
  45. VerticalAlignment="Center"
  46. Margin="5" />
  47. <TextBox Grid.Row="0"
  48. Grid.Column="1"
  49. Margin="5"
  50. MinWidth="240"
  51. Text="{Binding CurrentParkingLot.PartName, UpdateSourceTrigger=PropertyChanged}" />
  52. <TextBlock Grid.Row="1"
  53. Grid.Column="0"
  54. Text="数量:"
  55. VerticalAlignment="Center"
  56. Margin="5" />
  57. <TextBox Grid.Row="1"
  58. Grid.Column="1"
  59. Margin="5"
  60. Width="160"
  61. Text="{Binding CurrentParkingLot.Quantity, UpdateSourceTrigger=PropertyChanged}" />
  62. <StackPanel Grid.Row="2"
  63. Grid.Column="0"
  64. Grid.ColumnSpan="2"
  65. Orientation="Horizontal"
  66. HorizontalAlignment="Center"
  67. Margin="0,16,0,0">
  68. <Button Content="添加"
  69. Width="80"
  70. Height="30"
  71. Margin="10"
  72. Command="{Binding AddCommand}" />
  73. <Button Content="更新"
  74. Width="80"
  75. Height="30"
  76. Margin="10"
  77. Command="{Binding UpdateCommand}"
  78. IsEnabled="{Binding IsEditMode}" />
  79. <Button Content="取消编辑"
  80. Width="90"
  81. Height="30"
  82. Margin="10"
  83. Command="{Binding CancelEditCommand}"
  84. IsEnabled="{Binding IsEditMode}" />
  85. <Button Content="清空"
  86. Width="80"
  87. Height="30"
  88. Margin="10"
  89. Command="{Binding ClearFormCommand}" />
  90. </StackPanel>
  91. </Grid>
  92. </GroupBox>
  93. <GroupBox Grid.Row="2"
  94. Header="零件列表">
  95. <Grid>
  96. <Grid.RowDefinitions>
  97. <RowDefinition Height="*" />
  98. <RowDefinition Height="Auto" />
  99. </Grid.RowDefinitions>
  100. <DataGrid Grid.Row="0"
  101. AutoGenerateColumns="False"
  102. ItemsSource="{Binding ParkingLots}"
  103. SelectedItem="{Binding SelectedParkingLot, Mode=TwoWay}"
  104. CanUserAddRows="False"
  105. CanUserDeleteRows="False"
  106. SelectionMode="Single"
  107. SelectionUnit="FullRow"
  108. Margin="5"
  109. IsReadOnly="True">
  110. <DataGrid.Columns>
  111. <DataGridTextColumn Header="名称"
  112. Binding="{Binding PartName}"
  113. Width="*"
  114. MinWidth="160" />
  115. <DataGridTextColumn Header="数量"
  116. Binding="{Binding Quantity}"
  117. Width="100" />
  118. <DataGridTemplateColumn Header="操作"
  119. Width="160">
  120. <DataGridTemplateColumn.CellTemplate>
  121. <DataTemplate>
  122. <StackPanel Orientation="Horizontal">
  123. <Button Content="编辑"
  124. Width="56"
  125. Margin="2"
  126. Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=DataGrid}}"
  127. CommandParameter="{Binding}" />
  128. <Button Content="删除"
  129. Width="56"
  130. Margin="2"
  131. Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource AncestorType=DataGrid}}"
  132. CommandParameter="{Binding}" />
  133. </StackPanel>
  134. </DataTemplate>
  135. </DataGridTemplateColumn.CellTemplate>
  136. </DataGridTemplateColumn>
  137. </DataGrid.Columns>
  138. </DataGrid>
  139. <StackPanel Grid.Row="1"
  140. Orientation="Horizontal"
  141. HorizontalAlignment="Right"
  142. Margin="5">
  143. <TextBlock Text="总计:"
  144. FontWeight="Bold"
  145. Margin="5" />
  146. <TextBlock Text="{Binding ParkingLots.Count}"
  147. Foreground="Blue"
  148. Margin="5" />
  149. <TextBlock Text="条"
  150. Margin="5" />
  151. </StackPanel>
  152. </Grid>
  153. </GroupBox>
  154. </Grid>
  155. </UserControl>