<UserControl x:Class="MainShell.Recipe.View.PidRecipeEditorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:behavior="clr-namespace:MainShell.Common.ControlAttribute"
             xmlns:mw="http://www.maxwell-gp.com/"
             mc:Ignorable="d"
             d:DesignHeight="700"
             d:DesignWidth="1180">
    <UserControl.Resources>
        <SolidColorBrush x:Key="PidPageBackgroundBrush" Color="#F4F7FB"/>
        <SolidColorBrush x:Key="PidCardBackgroundBrush" Color="#FFFFFF"/>
        <SolidColorBrush x:Key="PidCardBorderBrush" Color="#D6E0EA"/>
        <SolidColorBrush x:Key="PidHeaderBackgroundBrush" Color="#EEF3F8"/>
        <SolidColorBrush x:Key="PidHeaderForegroundBrush" Color="#2E5FA7"/>
        <SolidColorBrush x:Key="PidBodyTextBrush" Color="#425466"/>
        <SolidColorBrush x:Key="PidMutedTextBrush" Color="#6B7B8D"/>
        <SolidColorBrush x:Key="PidValueBrush" Color="#264B86"/>

        <Style x:Key="PidSectionBorderStyle" TargetType="Border">
            <Setter Property="Background" Value="{StaticResource PidCardBackgroundBrush}"/>
            <Setter Property="BorderBrush" Value="{StaticResource PidCardBorderBrush}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="CornerRadius" Value="4"/>
            <Setter Property="Padding" Value="0"/>
        </Style>

        <Style x:Key="PidSectionTitleStyle" TargetType="TextBlock">
            <Setter Property="Foreground" Value="{StaticResource PidHeaderForegroundBrush}"/>
            <Setter Property="FontSize" Value="15"/>
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>

        <Style x:Key="PidHintTextStyle" TargetType="TextBlock">
            <Setter Property="Foreground" Value="{StaticResource PidMutedTextBrush}"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="TextWrapping" Value="Wrap"/>
        </Style>

        <Style x:Key="PidFieldLabelStyle" TargetType="TextBlock" BasedOn="{StaticResource TextBlockStyle}">
            <Setter Property="Foreground" Value="{StaticResource PidBodyTextBrush}"/>
            <Setter Property="FontWeight" Value="SemiBold"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Margin" Value="0,6,10,6"/>
            <Setter Property="HorizontalAlignment" Value="Right"/>
        </Style>

        <Style x:Key="PidNumericOnlyEditingTextBoxStyle" TargetType="TextBox">
            <Setter Property="behavior:ControlBehavior.IsNumericOnly" Value="True"/>
            <Setter Property="Padding" Value="6,0"/>
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="HorizontalContentAlignment" Value="Right"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
            <Setter Property="SelectionTextBrush" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
        </Style>

        <Style x:Key="PidNumericDisplayTextStyle" TargetType="TextBlock">
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="TextAlignment" Value="Right"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Margin" Value="0"/>
        </Style>

        <Style x:Key="PidNumericOnlyTextBoxStyle" TargetType="TextBox">
            <Setter Property="behavior:ControlBehavior.IsNumericOnly" Value="True"/>
            <Setter Property="Margin" Value="4,2"/>
            <Setter Property="MinWidth" Value="120"/>
            <Setter Property="Height" Value="32"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
        </Style>

        <Style x:Key="PidPrimaryButtonStyle" TargetType="Button" BasedOn="{StaticResource StartButtonStyle}">
            <Setter Property="MinWidth" Value="108"/>
            <Setter Property="Height" Value="34"/>
            <Setter Property="Margin" Value="0,0,8,0"/>
        </Style>

        <Style x:Key="PidDangerButtonStyle" TargetType="Button" BasedOn="{StaticResource CloseButtonStyle}">
            <Setter Property="MinWidth" Value="108"/>
            <Setter Property="Height" Value="34"/>
            <Setter Property="Margin" Value="0,0,8,0"/>
        </Style>

        <Style x:Key="PidFilterToggleStyle" TargetType="CheckBox" BasedOn="{StaticResource ModernSwitchStyle}">
            <Setter Property="Margin" Value="4,2"/>
        </Style>

        <Style x:Key="PidAxisComboBoxStyle" TargetType="ComboBox">
            <Setter Property="Margin" Value="4,2"/>
            <Setter Property="MinWidth" Value="120"/>
            <Setter Property="Height" Value="32"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
        </Style>

        <Style x:Key="PidNumberBoxStyle" TargetType="mw:NumberBox">
            <Setter Property="Margin" Value="4,2"/>
            <Setter Property="MinWidth" Value="120"/>
            <Setter Property="Height" Value="32"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="mw:NumericKeypadAttach.IsEnabled" Value="True"/>
        </Style>

        <Style x:Key="PidTabItemStyle" TargetType="TabItem">
            <Setter Property="Padding" Value="20,8"/>
            <Setter Property="Foreground" Value="{StaticResource PidBodyTextBrush}"/>
            <Setter Property="FontWeight" Value="SemiBold"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="TabItem">
                        <Border x:Name="TabBorder"
                                Background="#E5E9EF"
                                BorderBrush="{StaticResource PidCardBorderBrush}"
                                BorderThickness="1,1,1,0"
                                Margin="0,0,2,0"
                                Padding="{TemplateBinding Padding}">
                            <ContentPresenter HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              ContentSource="Header"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="TabBorder" Property="Background" Value="#F4F8FE"/>
                            </Trigger>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter TargetName="TabBorder" Property="Background" Value="White"/>
                                <Setter TargetName="TabBorder" Property="BorderBrush" Value="{StaticResource PidHeaderForegroundBrush}"/>
                                <Setter Property="Foreground" Value="{StaticResource PidHeaderForegroundBrush}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Grid Background="{StaticResource PidPageBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Border Grid.Row="0"
                Margin="12,12,12,8"
                Padding="12,8"
                Background="White"
                BorderBrush="{StaticResource PidCardBorderBrush}"
                BorderThickness="1"
                CornerRadius="4">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="220"/>
                    <ColumnDefinition Width="12"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="12"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <TextBlock Text="选择配置组："
                           Style="{StaticResource PidFieldLabelStyle}"
                           VerticalAlignment="Center"
                           Margin="0,0,8,0"/>

                <ComboBox Grid.Column="1"
                          Margin="0"
                          Style="{StaticResource ProcessComboBoxStyle}"
                          ItemsSource="{Binding AxisPIDParameters}"
                          DisplayMemberPath="Name"
                          SelectedItem="{Binding SelectedPIDProfile, Mode=TwoWay}"
                          VerticalAlignment="Center"/>

                <Button Grid.Column="3"
                        Content="读取"
                        Style="{StaticResource PidPrimaryButtonStyle}"
                        Margin="0"
                        Click="{mw:Action ReadParameters}"/>

                <Button Grid.Column="5"
                        Content="写入"
                        Style="{StaticResource PidPrimaryButtonStyle}"
                        Margin="0"
                        Click="{mw:Action WriteParameters}"/>
            </Grid>
        </Border>

        <Border Grid.Row="1"
                Margin="12,0,12,8"
                Background="White"
                BorderBrush="{StaticResource PidCardBorderBrush}"
                BorderThickness="1"
                CornerRadius="4">
            <TabControl Background="Transparent"
                        BorderThickness="0"
                        SelectedIndex="{Binding SelectedParameterTabIndex, Mode=TwoWay}"
                        ItemContainerStyle="{StaticResource PidTabItemStyle}">
                <TabItem Header="PID 参数">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <TextBlock Grid.Row="0"
                                   Margin="12,8,12,6"
                                   Text="每个行对应一个轴的速度与位置环参数。"
                                   Style="{StaticResource PidHintTextStyle}"
                                   Foreground="{StaticResource PidHeaderForegroundBrush}"/>

                        <ScrollViewer Grid.Row="1"
                                      Margin="12,0,12,8"
                                      HorizontalScrollBarVisibility="Auto"
                                      VerticalScrollBarVisibility="Auto">
                            <DataGrid ItemsSource="{Binding SelectedAxes}"
                                      SelectedItem="{Binding SelectedAxisParameter, Mode=TwoWay}"
                                      AutoGenerateColumns="False"
                                      CanUserAddRows="False"
                                      CanUserDeleteRows="False"
                                      MinHeight="420"
                                      MinWidth="1100"
                                      ScrollViewer.CanContentScroll="True"
                                      ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                      ScrollViewer.VerticalScrollBarVisibility="Disabled">
                                <DataGrid.Columns>
                                    <DataGridTemplateColumn Header="轴 (Axis)" Width="180">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding ModuleName}" VerticalAlignment="Center"/>
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                        <DataGridTemplateColumn.CellEditingTemplate>
                                            <DataTemplate>
                                                <ComboBox ItemsSource="{Binding DataContext.AxisOptions, RelativeSource={RelativeSource AncestorType=UserControl}}"
                                                          DisplayMemberPath="AxisName"
                                                          SelectedValuePath="AxisName"
                                                          SelectedValue="{Binding ModuleName, UpdateSourceTrigger=PropertyChanged}"
                                                          Style="{StaticResource PidAxisComboBoxStyle}"/>
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellEditingTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTextColumn Header="SLVKP" Width="100"
                                                        Binding="{Binding PA_SLVKP.Value, UpdateSourceTrigger=PropertyChanged}"
                                                        ElementStyle="{StaticResource PidNumericDisplayTextStyle}"
                                                        EditingElementStyle="{StaticResource PidNumericOnlyEditingTextBoxStyle}"/>
                                    <DataGridTextColumn Header="SLVKI" Width="100"
                                                        Binding="{Binding PA_SLVKI.Value, UpdateSourceTrigger=PropertyChanged}"
                                                        ElementStyle="{StaticResource PidNumericDisplayTextStyle}"
                                                        EditingElementStyle="{StaticResource PidNumericOnlyEditingTextBoxStyle}"/>
                                    <DataGridTextColumn Header="SLVKPSF" Width="110"
                                                        Binding="{Binding PA_SLVKPSF.Value, UpdateSourceTrigger=PropertyChanged}"
                                                        ElementStyle="{StaticResource PidNumericDisplayTextStyle}"
                                                        EditingElementStyle="{StaticResource PidNumericOnlyEditingTextBoxStyle}"/>
                                    <DataGridTextColumn Header="SLVKPIF" Width="110"
                                                        Binding="{Binding PA_SLVKPIF.Value, UpdateSourceTrigger=PropertyChanged}"
                                                        ElementStyle="{StaticResource PidNumericDisplayTextStyle}"
                                                        EditingElementStyle="{StaticResource PidNumericOnlyEditingTextBoxStyle}"/>
                                    <DataGridTextColumn Header="SLVKISF" Width="110"
                                                        Binding="{Binding PA_SLVKISF.Value, UpdateSourceTrigger=PropertyChanged}"
                                                        ElementStyle="{StaticResource PidNumericDisplayTextStyle}"
                                                        EditingElementStyle="{StaticResource PidNumericOnlyEditingTextBoxStyle}"/>
                                    <DataGridTextColumn Header="SLVKIIF" Width="110"
                                                        Binding="{Binding PA_SLVKIIF.Value, UpdateSourceTrigger=PropertyChanged}"
                                                        ElementStyle="{StaticResource PidNumericDisplayTextStyle}"
                                                        EditingElementStyle="{StaticResource PidNumericOnlyEditingTextBoxStyle}"/>
                                    <DataGridTextColumn Header="SLPKP" Width="100"
                                                        Binding="{Binding PA_SLPKP.Value, UpdateSourceTrigger=PropertyChanged}"
                                                        ElementStyle="{StaticResource PidNumericDisplayTextStyle}"
                                                        EditingElementStyle="{StaticResource PidNumericOnlyEditingTextBoxStyle}"/>
                                    <DataGridTextColumn Header="SLPKPIF" Width="110"
                                                        Binding="{Binding PA_SLPKPIF.Value, UpdateSourceTrigger=PropertyChanged}"
                                                        ElementStyle="{StaticResource PidNumericDisplayTextStyle}"
                                                        EditingElementStyle="{StaticResource PidNumericOnlyEditingTextBoxStyle}"/>
                                    <DataGridTextColumn Header="SLPKPSF" Width="110"
                                                        Binding="{Binding PA_SLPKPSF.Value, UpdateSourceTrigger=PropertyChanged}"
                                                        ElementStyle="{StaticResource PidNumericDisplayTextStyle}"
                                                        EditingElementStyle="{StaticResource PidNumericOnlyEditingTextBoxStyle}"/>
                                    <DataGridTextColumn Header="SLAFF" Width="100"
                                                        Binding="{Binding PA_SLAFF.Value, UpdateSourceTrigger=PropertyChanged}"
                                                        ElementStyle="{StaticResource PidNumericDisplayTextStyle}"
                                                        EditingElementStyle="{StaticResource PidNumericOnlyEditingTextBoxStyle}"/>
                                </DataGrid.Columns>
                            </DataGrid>
                        </ScrollViewer>

                        <WrapPanel Grid.Row="2" Margin="12,0,12,12">
                            <Button Content="新增轴参数"
                                    Style="{StaticResource PidPrimaryButtonStyle}"
                                    Click="{mw:Action AddAxis}"/>
                            <Button Content="删除轴参数"
                                    Style="{StaticResource PidDangerButtonStyle}"
                                    Click="{mw:Action DeleteAxis}"/>
                        </WrapPanel>
                    </Grid>
                </TabItem>

                <TabItem Header="滤波参数">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="8"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <TextBlock Grid.Row="0"
                                   Margin="12,8,12,6"
                                   Text="每个行对应一个轴的滤波参数设置，请根据机械共振频率调整滤波参数。"
                                   Style="{StaticResource PidHintTextStyle}"
                                   Foreground="{StaticResource PidHeaderForegroundBrush}"/>

                        <Grid Grid.Row="1" Margin="12,0,12,0">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>

                            <TextBlock Margin="0,0,0,6"
                                       Text="陷波参数"
                                       Style="{StaticResource PidSectionTitleStyle}"/>

                            <ScrollViewer Grid.Row="1"
                                          HorizontalScrollBarVisibility="Auto"
                                          VerticalScrollBarVisibility="Auto">
                                <DataGrid ItemsSource="{Binding SelectedFilteringParameters}"
                                          SelectedItem="{Binding SelectedNotchFilteringParameter, Mode=TwoWay}"
                                          AutoGenerateColumns="False"
                                          CanUserAddRows="False"
                                          CanUserDeleteRows="False"
                                          MinHeight="200"
                                          MinWidth="900"
                                          ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                          ScrollViewer.VerticalScrollBarVisibility="Disabled">
                                    <DataGrid.Columns>
                                        <DataGridTemplateColumn Header="轴名称" Width="180">
                                            <DataGridTemplateColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding AxisDisplayName}" VerticalAlignment="Center"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellTemplate>
                                            <DataGridTemplateColumn.CellEditingTemplate>
                                                <DataTemplate>
                                                    <ComboBox ItemsSource="{Binding DataContext.AxisOptions, RelativeSource={RelativeSource AncestorType=UserControl}}"
                                                              DisplayMemberPath="AxisName"
                                                              SelectedValuePath="AxisIndex"
                                                              SelectedValue="{Binding AxisIndex, UpdateSourceTrigger=PropertyChanged}"
                                                              Style="{StaticResource PidAxisComboBoxStyle}"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellEditingTemplate>
                                        </DataGridTemplateColumn>
                                        <DataGridCheckBoxColumn Header="开启陷波" Width="90"
                                                                Binding="{Binding IsUseNotch.Value, UpdateSourceTrigger=PropertyChanged}"/>
                                        <DataGridTemplateColumn Header="陷波频率 (Hz)" Width="120">
                                            <DataGridTemplateColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding NotchFrequency.Value}" Style="{StaticResource PidNumericDisplayTextStyle}"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellTemplate>
                                            <DataGridTemplateColumn.CellEditingTemplate>
                                                <DataTemplate>
                                                    <mw:NumberBox Value="{Binding NotchFrequency.Value, UpdateSourceTrigger=PropertyChanged}"
                                                                  Style="{StaticResource PidNumberBoxStyle}"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellEditingTemplate>
                                        </DataGridTemplateColumn>
                                        <DataGridTemplateColumn Header="陷波宽度" Width="110">
                                            <DataGridTemplateColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding NotchWidth.Value}" Style="{StaticResource PidNumericDisplayTextStyle}"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellTemplate>
                                            <DataGridTemplateColumn.CellEditingTemplate>
                                                <DataTemplate>
                                                    <mw:NumberBox Value="{Binding NotchWidth.Value, UpdateSourceTrigger=PropertyChanged}"
                                                                  Style="{StaticResource PidNumberBoxStyle}"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellEditingTemplate>
                                        </DataGridTemplateColumn>
                                        <DataGridTemplateColumn Header="衰减" Width="110">
                                            <DataGridTemplateColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding NotchFalloff.Value}" Style="{StaticResource PidNumericDisplayTextStyle}"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellTemplate>
                                            <DataGridTemplateColumn.CellEditingTemplate>
                                                <DataTemplate>
                                                    <mw:NumberBox Value="{Binding NotchFalloff.Value, UpdateSourceTrigger=PropertyChanged}"
                                                                  Style="{StaticResource PidNumberBoxStyle}"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellEditingTemplate>
                                        </DataGridTemplateColumn>
                                    </DataGrid.Columns>
                                </DataGrid>
                            </ScrollViewer>
                        </Grid>

                        <Grid Grid.Row="3" Margin="12,0,12,8">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>

                            <TextBlock Margin="0,0,0,6"
                                       Text="低通参数"
                                       Style="{StaticResource PidSectionTitleStyle}"/>

                            <ScrollViewer Grid.Row="1"
                                          HorizontalScrollBarVisibility="Auto"
                                          VerticalScrollBarVisibility="Auto">
                                <DataGrid ItemsSource="{Binding SelectedFilteringParameters}"
                                          SelectedItem="{Binding SelectedLowPassFilteringParameter, Mode=TwoWay}"
                                          AutoGenerateColumns="False"
                                          CanUserAddRows="False"
                                          CanUserDeleteRows="False"
                                          MinHeight="200"
                                          MinWidth="760"
                                          ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                          ScrollViewer.VerticalScrollBarVisibility="Disabled">
                                    <DataGrid.Columns>
                                        <DataGridTemplateColumn Header="轴名称" Width="180">
                                            <DataGridTemplateColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding AxisDisplayName}" VerticalAlignment="Center"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellTemplate>
                                            <DataGridTemplateColumn.CellEditingTemplate>
                                                <DataTemplate>
                                                    <ComboBox ItemsSource="{Binding DataContext.AxisOptions, RelativeSource={RelativeSource AncestorType=UserControl}}"
                                                              DisplayMemberPath="AxisName"
                                                              SelectedValuePath="AxisIndex"
                                                              SelectedValue="{Binding AxisIndex, UpdateSourceTrigger=PropertyChanged}"
                                                              Style="{StaticResource PidAxisComboBoxStyle}"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellEditingTemplate>
                                        </DataGridTemplateColumn>
                                        <DataGridCheckBoxColumn Header="开启低通" Width="90"
                                                                Binding="{Binding IsUseFiltering.Value, UpdateSourceTrigger=PropertyChanged}"/>
                                        <DataGridTemplateColumn Header="低通频率 (Hz)" Width="130">
                                            <DataGridTemplateColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding FilteringFrequency.Value}" Style="{StaticResource PidNumericDisplayTextStyle}"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellTemplate>
                                            <DataGridTemplateColumn.CellEditingTemplate>
                                                <DataTemplate>
                                                    <mw:NumberBox Value="{Binding FilteringFrequency.Value, UpdateSourceTrigger=PropertyChanged}"
                                                                  Style="{StaticResource PidNumberBoxStyle}"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellEditingTemplate>
                                        </DataGridTemplateColumn>
                                        <DataGridTemplateColumn Header="阻尼系数" Width="130">
                                            <DataGridTemplateColumn.CellTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding FilteringDamping.Value}" Style="{StaticResource PidNumericDisplayTextStyle}"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellTemplate>
                                            <DataGridTemplateColumn.CellEditingTemplate>
                                                <DataTemplate>
                                                    <mw:NumberBox Value="{Binding FilteringDamping.Value, UpdateSourceTrigger=PropertyChanged}"
                                                                  Style="{StaticResource PidNumberBoxStyle}"/>
                                                </DataTemplate>
                                            </DataGridTemplateColumn.CellEditingTemplate>
                                        </DataGridTemplateColumn>
                                    </DataGrid.Columns>
                                </DataGrid>
                            </ScrollViewer>
                        </Grid>

                        <WrapPanel Grid.Row="4" Margin="12,0,12,12">
                            <Button Content="新增滤波参数"
                                    Style="{StaticResource PidPrimaryButtonStyle}"
                                    Click="{mw:Action AddFilteringParameter}"/>
                            <Button Content="删除滤波参数"
                                    Style="{StaticResource PidDangerButtonStyle}"
                                    Click="{mw:Action DeleteFilteringParameter}"/>
                        </WrapPanel>
                    </Grid>
                </TabItem>
            </TabControl>
        </Border>

        <Border Grid.Row="2"
                Margin="12,0,12,12"
                Padding="12,8"
                Background="White"
                BorderBrush="{StaticResource PidCardBorderBrush}"
                BorderThickness="1"
                CornerRadius="4">
            <TextBlock Text="说明：PID 配置组由程序初始化；每个配置组对应一组 PID 参数和滤波参数。"
                       Style="{StaticResource PidHintTextStyle}"/>
        </Border>
    </Grid>
</UserControl>