....
xmlns:viewmodel="clr-namespace:MyRecipe.ViewModels">
<navigation:Page.Resources>
<viewmodel:RecipeViewModel x:Key="RecipeViewModel" />
</navigation:Page.Resources>
<toolkit:DataForm x:Name="form"
HorizontalAlignment="Left" VerticalAlignment="Top"
ItemsSource="{Binding Recipes}" Width="500" Height="600" />
在viewmodel中:
public EntitySet<Recipe> Recipes
{
get { return _recipes; }
set
{
if (_recipes != value)
{
_recipes = value;
OnPropertyChanged("Recipes");
}
}
}
我想将数据表单绑定到Recipes实体集。数据形式未显示任何字段或任何指示它已绑定。怎么了?
答案 0 :(得分:0)
修正:
<toolkit:DataForm x:Name="form"
HorizontalAlignment="Left" VerticalAlignment="Top"
DataContext="{StaticResource RecipeViewModel}"
ItemsSource="{Binding Recipes}" Width="500" Height="600" />
必须添加DataContext行。