Files
MsAddIns/MSDevTool/Views/ElementInfoView.xaml
2026-02-28 21:01:57 +08:00

151 lines
6.7 KiB
XML

<Window
x:Class="MSDevTool.Views.ElementInfoView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MSDevTool"
xmlns:attach="clr-namespace:MSDevTool.Attached"
xmlns:vm="clr-namespace:MSDevTool.ViewModels"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:conv="clr-namespace:MSDevTool.Converters"
Title="查询"
Width="500"
Height="800"
MaxHeight="800"
d:DataContext="{d:DesignInstance Type=vm:ElementInfoViewModel}"
Topmost="True"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
<conv:TypeValueConverter x:Key="TypeValueConverter" />
<conv:TypeConverter x:Key="TypeConverter" />
<conv:NullToStringConverter x:Key="NullToStringConverter" />
<Style x:Key="GroupHeaderStyle" TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander Header="{Binding Name}" IsExpanded="False">
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="CellStyle" TargetType="DataGridCell">
<Style.Triggers>
<!-- 当值为整数类型时 -->
<!-- ClassPropValue -->
<DataTrigger Binding="{Binding Converter={StaticResource TypeConverter}}" Value="{x:Type sys:Int32}">
<Setter Property="Foreground" Value="OrangeRed" />
</DataTrigger>
<!-- 当值为字符串类型时 -->
<DataTrigger Binding="{Binding Converter={StaticResource TypeConverter}}" Value="{x:Type sys:String}">
<Setter Property="Foreground" Value="DarkGreen" />
</DataTrigger>
<!-- 当值为布尔类型时 -->
<DataTrigger Binding="{Binding Converter={StaticResource TypeConverter}}" Value="{x:Type sys:Boolean}">
<Setter Property="Foreground" Value="DarkBlue" />
</DataTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<DataGrid
Grid.Row="0"
Margin="5"
AutoGenerateColumns="False"
CanUserAddRows="False"
IsReadOnly="True"
ItemsSource="{Binding ClassPropValues}"
SelectionUnit="FullRow">
<b:Interaction.Triggers>
<b:EventTrigger EventName="MouseDoubleClick">
<b:InvokeCommandAction Command="{Binding ShowObjectCommand}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" />
</b:EventTrigger>
</b:Interaction.Triggers>
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="attach:ObjectType.IsMatchObject">
<Setter.Value>
<!-- Self=DataGridRow -->
<Binding Converter="{StaticResource TypeValueConverter}" RelativeSource="{RelativeSource Self}" />
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="attach:ObjectType.IsMatchObject" Value="True">
<!--<Setter Property="Foreground" Value="LightGreen" />-->
<Setter Property="FontWeight" Value="Bold" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
<DataGrid.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}">
<GroupStyle.Panel>
<ItemsPanelTemplate>
<DataGridRowsPresenter />
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</DataGrid.GroupStyle>
<DataGrid.Columns>
<DataGridTextColumn
Width="Auto"
Binding="{Binding PropName}"
Header="类属性名" />
<DataGridTextColumn
Width="*"
Binding="{Binding PropValue, Converter={StaticResource NullToStringConverter}}"
CellStyle="{StaticResource CellStyle}"
Header="属性值" />
<DataGridTextColumn
Width="*"
Binding="{Binding DataType}"
Header="数据类型" />
</DataGrid.Columns>
</DataGrid>
<DataGrid
Grid.Row="1"
Margin="5"
AutoGenerateColumns="False"
CanUserAddRows="False"
IsReadOnly="True"
ItemsSource="{Binding ECPropValues}"
SelectionUnit="Cell">
<DataGrid.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}">
<GroupStyle.Panel>
<ItemsPanelTemplate>
<DataGridRowsPresenter />
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</DataGrid.GroupStyle>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding LabelName}" Header="EC属性标签名" />
<DataGridTextColumn
Width="Auto"
Binding="{Binding PropName}"
Header="EC属性名" />
<DataGridTextColumn
Width="*"
Binding="{Binding PropValue, Converter={StaticResource NullToStringConverter}}"
CellStyle="{StaticResource CellStyle}"
Header="EC值" />
<DataGridTextColumn
Width="*"
Binding="{Binding DataType}"
Header="数据类型" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>