AlarmCard.xaml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <UserControl x:Class="NEIntelligentControl2.Views.Alarm.AlarmCard"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:NEIntelligentControl2.Views.Alarm"
  7. mc:Ignorable="d"
  8. d:DesignHeight="450" d:DesignWidth="800" Loaded="UserControl_Loaded">
  9. <UserControl.Resources>
  10. <ResourceDictionary>
  11. <Style x:Key="DataGridStyleMain" TargetType="{x:Type DataGrid}">
  12. <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
  13. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  14. <Setter Property="BorderBrush" Value="#FF688CAF"/>
  15. <Setter Property="BorderThickness" Value="1"/>
  16. <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>
  17. <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
  18. <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
  19. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  20. <Setter Property="Template">
  21. <Setter.Value>
  22. <ControlTemplate TargetType="{x:Type DataGrid}">
  23. <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
  24. <ScrollViewer x:Name="DG_ScrollViewer" Focusable="false">
  25. <ScrollViewer.Template>
  26. <ControlTemplate TargetType="{x:Type ScrollViewer}">
  27. <Grid>
  28. <Grid.ColumnDefinitions>
  29. <ColumnDefinition Width="Auto"/>
  30. <ColumnDefinition Width="*"/>
  31. <ColumnDefinition Width="Auto"/>
  32. </Grid.ColumnDefinitions>
  33. <Grid.RowDefinitions>
  34. <RowDefinition Height="Auto"/>
  35. <RowDefinition Height="*"/>
  36. <RowDefinition Height="Auto"/>
  37. </Grid.RowDefinitions>
  38. <Button Command="{x:Static DataGrid.SelectAllCommand}" Focusable="false" Style="{DynamicResource {ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}}" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
  39. <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Grid.Column="1" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
  40. <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" Grid.ColumnSpan="2" Grid.Row="1"/>
  41. <ScrollBar x:Name="PART_VerticalScrollBar" Grid.Column="2" MinWidth="7" Width="7" Maximum="{TemplateBinding ScrollableHeight}" Orientation="Vertical" Grid.Row="1" Grid.RowSpan="3" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Style="{DynamicResource ScrollViewBarStyle}"/>
  42. <Grid Grid.Column="1" Grid.Row="2">
  43. <Grid.ColumnDefinitions>
  44. <ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
  45. <ColumnDefinition Width="*"/>
  46. </Grid.ColumnDefinitions>
  47. <ScrollBar x:Name="PART_HorizontalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableWidth}" Orientation="Horizontal" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
  48. </Grid>
  49. </Grid>
  50. </ControlTemplate>
  51. </ScrollViewer.Template>
  52. <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  53. </ScrollViewer>
  54. </Border>
  55. </ControlTemplate>
  56. </Setter.Value>
  57. </Setter>
  58. <Style.Triggers>
  59. <MultiTrigger>
  60. <MultiTrigger.Conditions>
  61. <Condition Property="IsGrouping" Value="true"/>
  62. <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
  63. </MultiTrigger.Conditions>
  64. <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
  65. </MultiTrigger>
  66. </Style.Triggers>
  67. </Style>
  68. </ResourceDictionary>
  69. </UserControl.Resources>
  70. <Grid Margin="23,23,23,57">
  71. <Grid.RowDefinitions>
  72. <RowDefinition Height="Auto"/>
  73. <RowDefinition/>
  74. </Grid.RowDefinitions>
  75. <Border BorderThickness="1" BorderBrush="#FF31B9FB">
  76. <TextBlock Margin="25,5" Text="{Binding Title, RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}}" Foreground="#FF31B9FB" FontSize="18" HorizontalAlignment="Left" FontWeight="Bold"/>
  77. </Border>
  78. <Border Grid.Row="1" BorderThickness="1,0,1,1" BorderBrush="#FF31B9FB">
  79. <DataGrid x:Name="_DGMain" BorderThickness="0" Background="#00FFFFFF" AutoGenerateColumns="False" IsReadOnly="True" Style="{DynamicResource DataGridStyleMain}" HorizontalGridLinesBrush="#FF7E7E7E" VerticalGridLinesBrush="#FF7E7E7E" HeadersVisibility="Column" SelectionUnit="CellOrRowHeader">
  80. <DataGrid.RowStyle>
  81. <Style TargetType="DataGridRow">
  82. <Style.Triggers>
  83. <DataTrigger Binding="{Binding Path=Rank}" Value="3">
  84. <Setter Property="Background" Value="Orange"/>
  85. </DataTrigger>
  86. <DataTrigger Binding="{Binding Path=Rank}" Value="4">
  87. <Setter Property="Background" Value="Orange"/>
  88. </DataTrigger>
  89. <DataTrigger Binding="{Binding Path=Rank}" Value="5">
  90. <Setter Property="Background" Value="#FFEA6248"/>
  91. </DataTrigger>
  92. </Style.Triggers>
  93. </Style>
  94. </DataGrid.RowStyle>
  95. <DataGrid.Columns>
  96. <DataGridTextColumn Header="时间" Binding="{Binding Path=Time}"/>
  97. <DataGridTextColumn Header="设备" Binding="{Binding Path=Title}"/>
  98. <DataGridTextColumn Header="报警" Binding="{Binding Path=Message}" MaxWidth="415"/>
  99. <DataGridTextColumn Header="类型" Binding="{Binding Path=AlarmType}"/>
  100. </DataGrid.Columns>
  101. </DataGrid>
  102. </Border>
  103. </Grid>
  104. </UserControl>