1

我的 ListPicker for WP 7.1 出现问题,我选择的值不显示绑定,而是显示我作为 ItemSource 的模型的对象名称。但是,当我转到 FullModeItemTemplate 时,我的绑定工作得很好。我检查了我的输出并且没有任何绑定错误..

这是我的代码。

public class TurnoverModel
{
    public string TurnoverId { get; set; }
    public string TurnoverDesc { get; set; }
}

我的模型作为集合传入 ItemSource

         <toolkit:ListPicker ItemsSource="{Binding TurnoverList}" Width="350" HorizontalAlignment="Left" Name="turnOverListPicker" SelectionMode="Multiple"}" Header="Turnover" SelectionChanged="OnTurnoverChanged">
            <toolkit:ListPicker.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding TurnoverDesc}"/>
                    </StackPanel>
                </DataTemplate>
            </toolkit:ListPicker.ItemTemplate>
            <toolkit:ListPicker.FullModeItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding TurnoverDesc}" Width="150"/>
                    </StackPanel>
                </DataTemplate>
            </toolkit:ListPicker.FullModeItemTemplate>
        </toolkit:ListPicker>

如果有人有任何想法为什么我的绑定不起作用,我将不胜感激所有答案,谢谢

4

1 回答 1

0
 <toolkit:ListPicker ItemsSource="{Binding TurnoverList}" Width="350" HorizontalAlignment="Left" Name="turnOverListPicker" SelectionMode="Multiple"}" Header="Turnover" SelectionChanged="OnTurnoverChanged"> 
<toolkit:ListPicker.FullModeItemTemplate>
 <DataTemplate> 
<StackPanel Orientation="Horizontal"> 
<TextBlock Text="{Binding TurnoverDesc}" Width="150"/>
 </StackPanel>
 </DataTemplate>
 </toolkit:ListPicker.FullModeItemTemplate>
 </toolkit:ListPicker> 

在 selectionchanged 事件上写:

 private void OnTurnoverChanged(object sender, SelectionChangedEventArgs e)
    {
     TurnoverModel selecteditem = e.AddedItems[0] as TurnoverModel;
     String turnoverId =selecteditem.TurnoverId;
     String turnoverDesc =selecteditem.TurnoverDesc; 
    }
========================================================================
于 2013-05-20T08:58:14.853 回答