<ui:ContentDialog x:Class="DMS.WPF.Views.Dialogs.MqttAliasBatchEditDialog"
                  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:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
                  xmlns:vm="clr-namespace:DMS.WPF.ViewModels.Dialogs"
                  d:DataContext="{d:DesignInstance vm:MqttAliasBatchEditDialogViewModel}"
                  Title="批量编辑MQTT别名"
                  PrimaryButtonText="确定"
                  CloseButtonText="取消"
                  PrimaryButtonCommand="{Binding ConfirmCommand}"
                  CloseButtonCommand="{Binding CloseCommand}"
                  DefaultButton="Primary"
                  Background="White"
                  mc:Ignorable="d"
                  >
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" 
                   Text="为目标MQTT服务器设置变量别名：" 
                   Margin="0,0,0,10" 
                   Style="{StaticResource BodyTextBlockStyle}" />

        <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,0,0,10">
            <TextBlock Text="MQTT服务器：" VerticalAlignment="Center" />
            <TextBlock Text="{Binding SelectedMqttServer.ServerName}" 
                       FontWeight="Bold" 
                       FontSize="16"
                       Margin="5,0,0,0" 
                       VerticalAlignment="Center" />
        </StackPanel>

        <DataGrid Grid.Row="2"
                  ItemsSource="{Binding VariableMqttAliases}"
                  AutoGenerateColumns="False"
                  CanUserAddRows="False"
                  CanUserDeleteRows="False"
                  Margin="0,0,0,10"
                  MinHeight="300"
                  MaxHeight="500">
            <DataGrid.Columns>
                <DataGridTextColumn Header="变量名称" 
                                    Binding="{Binding Variable.Name}" 
                                    IsReadOnly="True"
                                    Width="*" />
                <DataGridTextColumn Header="别名" 
                                    Binding="{Binding Alias}" 
                                    Width="*" />
            </DataGrid.Columns>
        </DataGrid>

        <StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right">
            <TextBox x:Name="PrefixTextBox" 
                     Width="150" 
                     Margin="0,0,10,0">
                <TextBox.Resources>
                    <VisualBrush x:Key="HintText" AlignmentX="Left" AlignmentY="Center" Stretch="None">
                        <VisualBrush.Visual>
                            <TextBlock Text="输入前缀" Foreground="Gray" Margin="5,0,0,0" />
                        </VisualBrush.Visual>
                    </VisualBrush>
                </TextBox.Resources>
                <TextBox.Style>
                    <Style TargetType="TextBox">
                        <Setter Property="Background" Value="White" />
                        <Style.Triggers>
                            <Trigger Property="Text" Value="">
                                <Setter Property="Background" Value="{StaticResource HintText}" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </TextBox.Style>
            </TextBox>
            <Button Content="应用前缀" 
                    Command="{Binding ApplySamePrefixCommand}" 
                    CommandParameter="{Binding Text, ElementName=PrefixTextBox}" />
        </StackPanel>
    </Grid>
</ui:ContentDialog>