windows phone数据绑定listpicker到字符串列表

时间:2013-07-30 19:42:51

标签: c# xaml binding windows-phone

我有一个在构造函数中初始化的字符串列表:

public List<String> m_Distances = new List<String>();
public List<String> Distances
{
    get
    {
        return m_Distances;
    }
}

以及构造函数:

listPickerDistance.ItemsSource = Distances;

现在在我的XAML中:

                <TextBlock Text="Distance" x:Name="textBlockDistance"/>
                <toolkit:ListPicker ItemsSource="{Binding}" x:Name="listPickerDistance">
                    <toolkit:ListPickerItem>
                        <DataTemplate>
                            <TextBlock Text="{Binding Distances, ElementName=listPickerDistanceSearch}"/>
                        </DataTemplate>
                    </toolkit:ListPickerItem>
                </toolkit:ListPicker>

你能帮我把列表绑定到listpicker吗? 应该很容易..不是吗?

1 个答案:

答案 0 :(得分:4)

这就是全部:

public List<String> m_Distances = new List<String>();
public List<String> Distances
{
    get
    {
        return m_Distances;
    }
}

listPickerDistance.ItemsSource = Distances;

<toolkit:ListPicker x:Name="listPickerDistance">

</toolkit:ListPicker>