欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

WPF DataGrid 使用 [xmal]

程序员文章站 2022-07-13 22:36:45
...
<pu:WindowX x:Class="GloveBoxInsp.IoPortViewer"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:GloveBoxInsp"
        mc:Ignorable="d"
        Title="IoPortViewer" Height="475.035" Width="428.234" WindowStyle="None" Loaded="WindowX_Loaded" Closing="WindowX_Closing" Closed="WindowX_Closed">
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="50"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Label Grid.Row="0" Grid.Column="0" x:Name="lb_IoDevice">连接IO设备:</Label>
            <ComboBox Grid.Row="0" Grid.Column="1" x:Name="comboBoxDigitalIo"  Margin="0" VerticalAlignment="Top" SelectionChanged="comboBoxDigitalIo_SelectionChanged"/>
            <Button Grid.Row="0" Grid.Column="2" x:Name="btnClose" Content="关闭窗口" Width="75" Click="btnClose_Click"/>
        </Grid>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <GroupBox x:Name="inportTable" Grid.Column="0" Header="输入信号">
                <DataGrid x:Name="inportDataGrid" ItemsSource="{Binding}"
                              BorderBrush="LightGray"
                              BorderThickness="1"
                              CanUserAddRows="False">
                    <pu:DataGridHelper.AutoGenerateCheckBoxStyle>
                        <Style TargetType="CheckBox"
                                   BasedOn="{StaticResource {x:Type CheckBox}}">
                            <Setter Property="pu:CheckBoxHelper.CheckBoxStyle"
                                        Value="Switch" />
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Path=(pu:CheckBoxHelper.CheckBoxStyle),RelativeSource={RelativeSource Self}}"
                                                 Value="Switch">
                                    <Setter Property="pu:CheckBoxHelper.CheckedBackground"
                                                Value="#72C81F" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </pu:DataGridHelper.AutoGenerateCheckBoxStyle>
                </DataGrid>
            </GroupBox>
            <GroupBox  Grid.Column="1" Header="输出信号">
                <DataGrid x:Name="outportDataGrid"  ItemsSource="{Binding}"
                              BorderBrush="LightGray"
                              BorderThickness="1"
                                
                                
                        
                          
                              >
                    <pu:DataGridHelper.AutoGenerateCheckBoxStyle>
                        <Style  TargetType="CheckBox"
                                   BasedOn="{StaticResource {x:Type CheckBox}}">
                            <Setter Property="pu:CheckBoxHelper.CheckBoxStyle"
                                        Value="Switch" />
                    
                            <Style.Triggers>
                                    
                                    <DataTrigger Binding="{Binding Path=(pu:CheckBoxHelper.CheckBoxStyle),RelativeSource={RelativeSource Self}}"
                                                 Value="Switch">
                                    <Setter Property="pu:CheckBoxHelper.CheckedBackground"
                                                Value="Red" />
                                </DataTrigger>
                            </Style.Triggers>
                            
                        </Style>
                    </pu:DataGridHelper.AutoGenerateCheckBoxStyle>
                </DataGrid>
            </GroupBox>
        </Grid>
        
        

    </Grid>
</pu:WindowX>

 

相关标签: C#知识点