alielie
2025-03-11 2e54b439c64e0adbb7e010243c1f33aa5fc5f503
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<pu:WindowX x:Class="HMI.AlarmInfoManage.AlarmSettingList"
            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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:HMI.AlarmInfoManage"
            xmlns:pw="https://opensource.panuon.com/wpf"
            xmlns:pu="https://opensource.panuon.com/wpf-ui"
            xmlns:ui="clr-namespace:HMI.UI;assembly=HMI.UI"
            xmlns:dp="clr-namespace:HMI.UI.DpUtil;assembly=HMI.UI"
            mc:Ignorable="d"
            Title="{Binding SelectedValue,Mode=OneWay}"
            SizeToContent="Height"
            pu:WindowXModalDialog.Buttons="OK"
            pu:WindowXModalDialog.OKButtonContent="{Binding Converter={StaticResource lc},ConverterParameter='App.Close'}"
            Width="800"
            Height="600"
            Style="{StaticResource ModalWindow}">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <pu:StyleDictionary Includes="TabControl"/>
                <ResourceDictionary Source="/HMI.UI;component/Resources/Font/Font.xaml"/>
                <ResourceDictionary Source="/HMI.UI;component/Style/Colors.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
 
    <Grid Margin="10">
        <Border BorderThickness="1" BorderBrush="Gray">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition />
                </Grid.RowDefinitions>
 
                <ListBox ItemsSource="{Binding Items}" SelectedValue="{Binding SelectedValue}" BorderThickness="0">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="Margin" Value="0"/>
                            <Setter Property="Padding" Value="0"/>
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="ListBoxItem">
                                        <Border x:Name="border" Background="LightGray" 
Padding="10" Margin="0" BorderThickness="0">
                                            <!-- 内容呈现器 -->
                                            <StackPanel>
                                                <ContentPresenter  Content="{TemplateBinding Content}" 
                   ContentStringFormat="{TemplateBinding ContentStringFormat}" 
                   ContentTemplate="{TemplateBinding ContentTemplate}"  />
                                            </StackPanel>
                                        </Border>
 
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsSelected" Value="True">
                                                <Setter TargetName="border" Property="Background" Value="White"/>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
 
                <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" 
                            Margin="0,0,0,10"
                                    dp:StackPanelHelper.ChildSpace="10">
                    <Button Style="{StaticResource AddBtn}" x:Name="addBtn" Click="Button_Click"/>
                    <Button Style="{StaticResource RfhBtn}" x:Name="refreshBtn" Click="Button_Click"/>
                    <Button Style="{StaticResource DelBtn}" x:Name="delBatchBtn" Click="Button_Click"/>
                </StackPanel>
 
                <DataGrid x:Name="table" Grid.Row="2"
         Style="{StaticResource DefaultDataGrid}" ItemsSource="{Binding Datasource}">
                    <DataGrid.Columns>
                        <DataGridTemplateColumn Header="" Width="Auto" CanUserResize="False">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox VerticalAlignment="Center" 
                                              IsChecked="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="#" CanUserResize="False">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Converter={StaticResource rowNumber},
RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow},AncestorLevel=1}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTextColumn Width="*" Binding="{Binding DBAddress}" Header="DB地址" />
                        <DataGridTextColumn Width="*" Binding="{Binding StartAddress}" Header="起始地址" />
                        <DataGridTextColumn Width="*" Binding="{Binding Length}" Header="DB长度" />
                        <DataGridTemplateColumn Header="操作" Width="100" IsReadOnly="True" CanUserResize="False">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <Button x:Name="editBtn" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow},AncestorLevel=1}}" 
                                                Style="{StaticResource RowLink}" 
        Margin="0,0,10,0" 
        Click="Button_Click"
        DataContext="{Binding }">编辑</Button>
                                        <Button x:Name="delBtn" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow},AncestorLevel=1}}" 
                                                Style="{StaticResource DangerLinkButton}" 
        DataContext="{Binding }"
        Click="Button_Click">删除</Button>
                                    </StackPanel>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                    </DataGrid.Columns>
                </DataGrid>
            </Grid>
        </Border>
    </Grid>
</pu:WindowX>