0
....
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" />

在视图模型中:

public EntitySet<Recipe> Recipes
{
    get { return _recipes; }
    set
    {
        if (_recipes != value)
        {
            _recipes = value;
            OnPropertyChanged("Recipes");
        }
    }
}

我想将数据表单绑定到食谱实体集。数据表单未显示任何字段或任何已绑定的指示。怎么了?

4

1 回答 1

0

固定的:

<toolkit:DataForm x:Name="form" 
HorizontalAlignment="Left" VerticalAlignment="Top"
DataContext="{StaticResource RecipeViewModel}" 
ItemsSource="{Binding Recipes}" Width="500" Height="600" />

必须添加 DataContext 行。

于 2011-05-12T13:32:53.077 回答