简体   繁体   中英

Data binding with ListPicker issue

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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