【发布时间】:2013-02-27 11:24:29
【问题描述】:
我有一个Dictionary<string,string>,其中包含一些我想在ListView 中显示的数据。 ListView 绝对“看到”正确数量的项目(因为我从第二个 TextBlock 中看到了适当数量的冒号),但它既不显示 Key 也不显示 Value 绑定。
我需要Converter 还是什么?
我是否需要更改并改用ObservableCollection<KeyValuePair<string,string>>?
<ListView Grid.Row="1" IsItemClickEnabled="False"
SelectionMode="None" IsHitTestVisible="False"
IsSwipeEnabled="False"
ItemsSource="{Binding SymbolInfoText}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Key}"/>
<TextBlock Text=": "/>
<TextBlock Text="{Binding Value}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
public Dictionary<string, string> SymbolInfoText
{
get
{
if (selectedItem == null)
{
return new Dictionary<string, string> { { "Error", "No Item Selected" } };
}
return selectedItem.GenerateObjectProperties(CurrentLocation, LocalMapManager.Map.Heading);
}
}
【问题讨论】:
-
我在我们的代码中找不到错误。根据您的描述,这不是绑定问题。这与
Dictionary中的数据有关。请使用您的.cs文件的完整代码更新您的帖子。
标签: c# data-binding windows-store-apps winrt-xaml windows-store