<Window x:Class="LineChartDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:oxy="http://oxyplot.org/wpf"
        Title="{DynamicResource WatchData}" WindowState="Maximized"   Height="768" Width="1024"
          Loaded="Window_Loaded"
        Background="#F0F2F5">

    <!-- 1. 先定义资源（在所有引用之前） -->
    <Window.Resources>
        <!-- 圆角按钮样式：确保Key是“RoundedButtonStyle”，无拼写错误 -->
        <Style x:Key="RoundedButtonStyle" TargetType="Button">
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="Background" Value="#42A5F5"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border 
                            Background="{TemplateBinding Background}" 
                            CornerRadius="6"
                            Padding="{TemplateBinding Padding}">
                            <ContentPresenter 
                                HorizontalAlignment="Center" 
                                VerticalAlignment="Center"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Name, RelativeSource={RelativeSource Self}}" Value="StopBtn">
                    <Setter Property="Background" Value="#EF5350"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Name, RelativeSource={RelativeSource Self}}" Value="ClearBtn">
                    <Setter Property="Background" Value="#FFB74D"/>
                    <Setter Property="Foreground" Value="#2D3748"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>

    <!-- 2. 再定义布局（引用资源） -->
    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <!-- 标题区域 -->
        <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="10" VerticalAlignment="Center">
            <TextBlock Text="{DynamicResource WatchData1}" FontSize="22" FontWeight="Bold" Foreground="#2D3748" Margin="0,10"/>
            <TextBlock x:Name="StatusText" Margin="30,0,0,0" FontSize="16" Foreground="#4CAF50" Text="状态：已连接"/>
        </StackPanel>

        <!-- 主图表区域 -->
        <Border Grid.Row="1" Margin="10" Background="White" CornerRadius="8" BorderBrush="#E2E8F0" BorderThickness="1">
            <oxy:PlotView x:Name="PlotView" Margin="20"/>
        </Border>

        <!-- 控制按钮区域（引用样式，确保Key与资源一致） -->
        <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="10" HorizontalAlignment="Center" Height="60">
            <!-- 引用RoundedButtonStyle，确保名称完全匹配 -->
            <Button x:Name="StartBtn" Content="{DynamicResource WatchData2}" Width="140" Height="45" FontSize="16" 
                    Margin="10" Style="{StaticResource RoundedButtonStyle}"/>
            <Button x:Name="StopBtn" Content="{DynamicResource WatchData3}" Width="140" Height="45" FontSize="16" 
                    Margin="10" Style="{StaticResource RoundedButtonStyle}" IsEnabled="False"/>
            <Button x:Name="ClearBtn" Content="{DynamicResource WatchData4}" Width="140" Height="45" FontSize="16" 
                    Margin="10" Style="{StaticResource RoundedButtonStyle}"/>
        </StackPanel>
    </Grid>
</Window>