<UserControl
    x:Class="BPASmartClient.Control.DeviceMonitorView"
    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:local="clr-namespace:BPASmartClient.Control"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">
    <UserControl.DataContext>
        <vm:DeviceMonitorViewModel />
    </UserControl.DataContext>

    <UserControl.Resources>
        <!--#region ListBox样式-->
        <Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="BorderBrush" Value="{x:Null}" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontSize" Value="20" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border x:Name="border" CornerRadius="8">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </Border>
                        <!--<ControlTemplate.Triggers>
                                        <Trigger Property="IsSelected" Value="True">
                                            <Setter TargetName="border" Property="Background">
                                                <Setter.Value>
                                                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                                        <GradientStop Offset="0.5" Color="#FF6B6B6B" />
                                                        <GradientStop Offset="0.5" Color="#FF535353" />
                                                        <GradientStop Offset="0.022" Color="#FF535353" />
                                                        <GradientStop Offset="0.991" Color="#FF555555" />
                                                    </LinearGradientBrush>
                                                </Setter.Value>
                                            </Setter>
                                        </Trigger>
                                    </ControlTemplate.Triggers>-->
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <!--#endregion-->
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <!--  第一行是设备切换行  -->
        <ListBox
            x:Name="lstEnt"
            Margin="100,0,0,0"
            Background="{x:Null}"
            BorderBrush="{x:Null}"
            BorderThickness="0"
            ItemContainerStyle="{StaticResource ResourceKey=ListBoxItemStyle1}"
            ItemsSource="{Binding Devices}">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <RadioButton
                            Margin="0,0,10,0"
                            HorizontalContentAlignment="Center"
                            VerticalContentAlignment="Center"
                            Command="{Binding DataContext.DeviceSwitch, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}"
                            CommandParameter="{Binding Namespace}"
                            Content="{Binding Name}"
                            GroupName="Devices"
                            Style="{StaticResource RectangleRadioButtonStyle}" />
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>


        <!--  第二行是设备功能行  -->
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <ItemsControl ItemsSource="{Binding DeviceMonitors}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <RadioButton
                                Margin="0,10,0,10"
                                HorizontalContentAlignment="Center"
                                VerticalContentAlignment="Center"
                                Command="{Binding DataContext.DeviceWindowSwitch, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"
                                CommandParameter="{Binding Namespace}"
                                Content="{Binding Name}"
                                FontSize="16"
                                GroupName="DeviceMotion"
                                Style="{StaticResource RectangleLeftRadioButtonStyle}" />
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>

            <ContentControl Grid.Column="1" Content="{Binding MainContent}" />

        </Grid>


    </Grid>
</UserControl>
