运行效果图
程序集整体如下
<Window x:Class="MVVMLightDemo.View.MainView" 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:MVVMLightDemo.View" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" mc:Ignorable="d" Title="MainView" Height="450" Width="800"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="100"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <StackPanel Grid.Column ="0"> <Button Content="UI1" Command="{Binding UI1Command}" /> <Button Content="UI2" Command="{Binding UI2Command}"/> </StackPanel> <GridSplitter Grid.Row="0" Grid.Column="1" Width="5" HorizontalAlignment="Left" VerticalAlignment="Stretch" Background="#FFC1BDC5" Grid.RowSpan="2" /> <Grid Grid.Column="1"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="100"/> </Grid.RowDefinitions> <GridSplitter Height="5" Grid.Row="0" Grid.Column="1" Background="#FFC1BDC5" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/> <Border Grid.Row ="0" BorderBrush="Gray" BorderThickness="1" > <ContentPresenter Content="{Binding Content}" Margin="5,0"/> <!--使用内容呈现器来切换界面--> </Border> <Border Grid.Row ="1" BorderBrush="Gray" BorderThickness="1"> <TextBox x:Name="LogTextBox" Text="{Binding TextLog}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" > <i:Interaction.Triggers> <i:EventTrigger EventName="Loaded"> <i:InvokeCommandAction Command="{Binding Path=TextBoxLoadedCommand}" CommandParameter="{Binding ElementName=LogTextBox}"> </i:InvokeCommandAction> </i:EventTrigger> </i:Interaction.Triggers> </TextBox> </Border> </Grid> </Grid> </Window>