103 lines
4.8 KiB
Plaintext
103 lines
4.8 KiB
Plaintext
|
|
<Window
|
||
|
|
x:Class="MSDevTool.Views.ObjectView"
|
||
|
|
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: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"
|
||
|
|
xmlns:attach="clr-namespace:MSDevTool.Attached"
|
||
|
|
Title="对象窗口"
|
||
|
|
Width="400"
|
||
|
|
Height="800"
|
||
|
|
MaxHeight="800"
|
||
|
|
d:DataContext="{d:DesignInstance Type=vm:ObjectViewModel}"
|
||
|
|
SizeToContent="Height"
|
||
|
|
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>
|
||
|
|
<!-- 当值为整数类型时 -->
|
||
|
|
<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>
|
||
|
|
<DataGrid
|
||
|
|
Margin="5"
|
||
|
|
AutoGenerateColumns="False"
|
||
|
|
CanUserAddRows="False"
|
||
|
|
IsReadOnly="True"
|
||
|
|
ItemsSource="{Binding PropValues}"
|
||
|
|
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=单元格 Path="Content.Text" Content是TextBlock -->
|
||
|
|
<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.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>
|
||
|
|
</Grid>
|
||
|
|
</Window>
|