开发者

Data binding with ListPicker issue

开发者 https://www.devze.com 2023-01-30 07:18 出处:网络
I am trying to bind the data from linq xml in isolated storage. The data templates (ItemTemplate and FullModeItemTemplate) work fine and only show the value saved in the element or attribute in thexml

I am trying to bind the data from linq xml in isolated storage. The data templates (ItemTemplate and FullModeItemTemplate) work fine and only show the value saved in the element or attribute in the xml document.

            <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!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号