Xaml 绑定到ComboBox时出现UWP异常
我得到一个例外: AppName.exe中发生未经处理的win32异常 只有当我绑定到组合框时才会发生这种情况 这是我的XAML:Xaml 绑定到ComboBox时出现UWP异常,xaml,combobox,uwp,Xaml,Combobox,Uwp,我得到一个例外: AppName.exe中发生未经处理的win32异常 只有当我绑定到组合框时才会发生这种情况 这是我的XAML: <ContentDialog x:Name="BrowseBySourceDialog" Grid.Column="1" PrimaryButtonTe
<ContentDialog x:Name="BrowseBySourceDialog"
Grid.Column="1"
PrimaryButtonText="Accept" IsPrimaryButtonEnabled="False"
Opened="BrowseBySourceDialog_Opened">
<StackPanel Background="White">
<Border Background="DarkGreen" MinHeight="40"
MinWidth="300">
<TextBlock Text="Browse: By Source"
VerticalAlignment="Center"
Foreground="White"
TextAlignment="Center"
HorizontalAlignment="Center" />
</Border>
<StackPanel>
<ComboBox x:Name="BrowseBySourceComboBox"
PlaceholderText="Select Source"
Height="40"
Width="300"
ItemsSource="{x:Bind BrowseBySourceList, Mode=OneWay}"
DisplayMemberPath="Source">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="local:FeaturedResponseItem">
<TextBlock Text="{x:Bind key}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
</StackPanel>
</ContentDialog>
您可以删除
displaymberpath=“Source”
,或者只需一起删除ItemTemplate
,然后将displaymberpath=“Source”
更改为displaymberpath=“Key”源代码的类型是什么?@JustinXL更新了我的问题
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="local:FeaturedResponseItem">
<TextBlock Text="{x:Bind key}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
ObservableCollection<FeaturedResponseItem> BrowseBySourceList { get; set; } = new ObservableCollection<FeaturedResponseItem>();
public class FeaturedResponseItem
{
public string key { get; set; }
public string icon { get; set; }
public bool accessible { get; set; }
}