简体   繁体   English

数据绑定与ListPicker问题

[英]Data binding with ListPicker issue

I am trying to bind the data from linq xml in isolated storage. 我试图从隔离存储中的linq xml绑定数据。 The data templates (ItemTemplate and FullModeItemTemplate) work fine and only show the value saved in the element or attribute in the xml document. 数据模板(ItemTemplate和FullModeItemTemplate)可以正常工作,并且仅显示保存在xml文档的元素或属性中的值。

            <toolkit:ListPicker.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding BindName}" Margin="0"/>
                </DataTemplate>
            </toolkit:ListPicker.ItemTemplate>
            <toolkit:ListPicker.FullModeItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Margin="16,21,0,20">
                        <TextBlock Text="{Binding BindName}" Margin="16,0,0,0" FontSize="43" FontFamily="{StaticResource PhoneFontFamilyLight}"/>
                    </StackPanel>
                </DataTemplate>
            </toolkit:ListPicker.FullModeItemTemplate>

However, although on the listpicker when selected it appears to use this name, the actual value held by the list picker is: 但是,尽管在选择列表选择器时,它似乎使用了此名称,但列表选择器保留的实际值为:

appname.pagename + namestringusedwhensetting

The name of the string comes from where I set it I presume. 字符串的名称来自我设定的位置。 I am using this method: 我正在使用这种方法:

    public class BindingSetter
    {
        string sValue;

        public string SValueN
        {
            get { return sValue; }
            set { sValue = value; }
        }
    }

So it is returning: 因此它正在返回:

appname.pagename + sValue

I have used binding throughout my application and have not had this problem before so i am a bit stumped. 我已经在整个应用程序中使用了绑定,并且之前没有遇到过这个问题,所以我有些困惑。

Thanks in advance. 提前致谢。

I have managed to work it out. 我设法解决了。 To use the value on the selected item I used: 要在我使用的所选项目上使用值:

((appname.PageName.ClassUsedToBindData)(ListPickerName.SelectedItem)).String

eg. 例如。

((calculator.MainPage.CalculateBinding)(FunctionSelector.SelectedItem)).Function

Hope this helps anyone who is struggling like I was! 希望这对像我一样挣扎的人有所帮助!

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

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