можно на подобии сделать
Код:
<Window x:Class="OliverCode.MVVM.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MVVM Demostration" Height="297" Width="480"
xmlns:views="clr-namespace:OliverCode.MVVM.View">
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="460*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="80*"/>
</Grid.RowDefinitions>
<Border CornerRadius="5" BorderBrush="SteelBlue" BorderThickness="2" Grid.Row="0">
<Label Height="30" Width="400" Content="Below is a two way binding between the view view-model, and model"/>
</Border>
<Border CornerRadius="5" BorderBrush="SteelBlue" BorderThickness="2" Grid.Row="1" Margin="0,5,0,0">
<views:PersonView/>
</Border>
</Grid>
</Window>
Вложение:
1.jpg [ 31.3 КиБ | Просмотров: 2076 ]
описание внешнего вида находится между
Код:
<Grid Margin="10"> ... </Grid>
а это что из себя представляет <views:PersonView/>:
Код:
<UserControl x:Class="OliverCode.MVVM.View.PersonView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="Auto" Width="Auto"
xmlns:local="clr-namespace:OliverCode.MVVM.ViewModel">
<StackPanel Orientation="Vertical" Margin="4">
<!--Here is where we the view gets a copy to the ViewModel Declaratively-->
<StackPanel.DataContext>
<local:PersonViewModel />
</StackPanel.DataContext>
<StackPanel Orientation="Vertical" DataContext="{Binding Path=Person, Mode=TwoWay}" Margin="4">
<StackPanel Orientation="Horizontal">
<Label Content="First Name:" Margin="0,0,4,0"/>
<TextBox Width="250" Text="{Binding Path=FirstName}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<Label Content="Last Name:" Margin="0,0,4,0"/>
<TextBox Width="250" Text="{Binding Path=LastName}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<Label Content="Age:" Margin="35,0,4,0"/>
<TextBox Width="50" MaxLength="3" Text="{Binding Path=Age}"/>
</StackPanel>
</StackPanel>
<StackPanel>
<Button Content="Save" HorizontalAlignment="Right" Width="80" Command="{Binding Path=SavePersonCommand}"/>
</StackPanel>
</StackPanel>
</UserControl>
Вложение:
2.jpg [ 11.34 КиБ | Просмотров: 2100 ]
можно и динамически подгружаемым/изменяемым сделать. вопрос в том, есть ли желание делать что-то подобное.