Newer
Older
Correlator / Correlator / Dialog / SoundSampleRateDialog.xaml
<UserControl
    x:Class="Correlator.Dialog.SoundSampleRateDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
    xmlns:cvt="clr-namespace:Correlator.Converter"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:hc="https://handyorg.github.io/handycontrol"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:prism="http://prismlibrary.com/"
    xmlns:vm="clr-namespace:Correlator.ViewModels"
    Width="1096"
    Height="635"
    d:DataContext="{d:DesignInstance Type=vm:SoundSampleRateDialogViewModel}"
    Background="White"
    mc:Ignorable="d">

    <prism:Dialog.WindowStyle>
        <Style TargetType="Window">
            <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterOwner" />
            <Setter Property="ShowInTaskbar" Value="False" />
            <Setter Property="ResizeMode" Value="NoResize" />
            <Setter Property="SizeToContent" Value="WidthAndHeight" />
        </Style>
    </prism:Dialog.WindowStyle>

    <UserControl.Resources>
        <cvt:WorkModeConverter x:Key="WorkModeConverterKey" />
    </UserControl.Resources>

    <Grid>
        <DataGrid
            x:Name="TargetDataGrid"
            hc:DataGridAttach.CanUnselectAllWithBlankArea="True"
            AutoGenerateColumns="False"
            CanUserSortColumns="False"
            CellStyle="{StaticResource DataGridCellCustomStyleKey}"
            ColumnHeaderHeight="60"
            FontSize="18"
            HeadersVisibility="All"
            ItemsSource="{Binding SampleRateCollection}"
            RowHeight="60"
            RowStyle="{StaticResource DataGridRowCustomStyleKey}">

            <b:Interaction.Triggers>
                <b:EventTrigger EventName="SelectionChanged">
                    <b:InvokeCommandAction Command="{Binding ItemSelectedCommand}" CommandParameter="{Binding ElementName=TargetDataGrid, Path=SelectedItem}" />
                </b:EventTrigger>
            </b:Interaction.Triggers>

            <DataGrid.Columns>
                <DataGridTextColumn
                    Width="*"
                    Binding="{Binding WorkMode, Converter={StaticResource WorkModeConverterKey}}"
                    Foreground="{StaticResource PrimaryTextBrush}"
                    Header="工作模式"
                    IsReadOnly="True" />
                <DataGridTextColumn
                    Width="*"
                    Binding="{Binding SampleRate}"
                    Foreground="{StaticResource PrimaryTextBrush}"
                    Header="采样率(Hz)"
                    IsReadOnly="True" />
                <DataGridTextColumn
                    Width="*"
                    Binding="{Binding UpdateDate}"
                    Foreground="{StaticResource PrimaryTextBrush}"
                    Header="更新时间"
                    IsReadOnly="True" />
                <DataGridTemplateColumn
                    Width="70"
                    CanUserResize="False"
                    Header="操作">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button
                                HorizontalAlignment="Left"
                                BorderThickness="0"
                                Command="{Binding DataContext.EditSampleRateCommand, ElementName=TargetDataGrid}"
                                Style="{StaticResource ButtonInfo}">
                                <TextBlock
                                    VerticalAlignment="Center"
                                    FontFamily="/Correlator;component/Fonts/#iconfont"
                                    FontSize="20"
                                    Text="&#xe66f;" />
                            </Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>