如何从视图模型中更新此元素

时间:2018-11-15 20:19:07

标签: c# wpf material-design

我正在使用Material Design工具箱,并且我想通过某种方式将DrawerHost设置为从具有属性的视图模型中打开或关闭。我在视图模型中有一个属性,该属性已经从另一个来源进行了更新。我只需要将该属性转换为xaml。任何帮助表示赞赏。

<UserControl x:Class="GS.Server.Focuser.FocuserView"
         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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
         mc:Ignorable="d">
<materialDesign:DrawerHost  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="2" 
        IsLeftDrawerOpen="{Binding ElementName=MenuToggleButton, Path=IsChecked}" 
        BorderBrush="{DynamicResource MaterialDesignDivider}">
    <materialDesign:DrawerHost.LeftDrawerContent>
        <Grid Width="700">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <StackPanel Grid.Row="0">
                <ToggleButton DockPanel.Dock="Top" HorizontalAlignment="Right" Margin="5" 
                    Style="{StaticResource MaterialDesignHamburgerToggleButton}" 
                    Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
                    CommandParameter="{x:Static Dock.Left}"
                    IsChecked="{Binding ElementName=MenuToggleButton, Path=IsChecked, Mode=TwoWay}"/>
            </StackPanel>
            <Label Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center">Focuser Settings Go Here</Label>
        </Grid>
    </materialDesign:DrawerHost.LeftDrawerContent>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <ToggleButton Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Top"
            Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
            CommandParameter="{x:Static Dock.Left}"
            Style="{StaticResource MaterialDesignHamburgerToggleButton}" IsChecked="False"
                          x:Name="MenuToggleButton"/>
        <TextBlock Grid.Row="1" Text="This is the Focuser Page" 
                       FontWeight="Bold" FontSize="18"
                       HorizontalAlignment="Center" VerticalAlignment="Center" />
    </Grid>
</materialDesign:DrawerHost>

0 个答案:

没有答案