繁体   English   中英

如何在XAML中绑定数据形式

[英]How to bind dataform in XAML

....
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");
        }
    }
}

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

固定:

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

必须添加DataContext行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM