在mMaterialCentreGroupListView.xaml
文件中,这一行是为MaterialCentreGroupView
. 但我看不到任何用于访问 viewmodel 属性的数据上下文。它运作良好。下面是代码。
<vw:MaterialCentreGroupView
Style="{StaticResource DetailedViewStyle}"
DataContext="{Binding SelectedMaterialCentreGroup}"/>
风景
<UserControl x:Class="MyBooks.View.MaterialCentreGroupView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
MinWidth="290" MaxWidth="290" Padding="20"
Background="#eee">
<UserControl.Resources>
<ResourceDictionary Source="ViewResources.xaml" />
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label
Grid.Row="0" Grid.Column="0"
Content="{Resx ResxName=MyBooks.Properties.Strings, Key=AccountCategoryListView_Name_Label}"
HorizontalAlignment="Right"/>
<TextBox
x:Name="CategoryName"
MaxLength="50"
Style="{StaticResource FormControlStyle}"
Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2"
Text="{Binding Path=Name, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"/>
请向我解释发生了什么以及绑定是如何发生的?