【发布时间】:2016-12-19 04:52:36
【问题描述】:
我使用 template10 创建了一个新项目,我正在处理一个简单的表单:我从远程服务器加载一个项目列表到一个组合框中,并在加载列表后选择其中一个项目。
我尝试设置 SelectedValue、SelectedItem 和 SelectedIndex,但是当显示表单时,列表框未选中。
我错过了什么吗?
这是xaml
<ComboBox x:Name="voceSpesaCb" Margin="16,16,0,0"
RelativePanel.AlignLeftWith="parameterResizer"
RelativePanel.Below="voceSpesaTextBlock"
DisplayMemberPath="Descrizione"
SelectedValue="{x:Bind ViewModel.VoceCorrente, Converter={StaticResource XConverter}, Mode=TwoWay}"
ItemsSource="{x:Bind ViewModel.Voci, Converter={StaticResource XConverter}}"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
这是代码
Voci = await vociSpesaTable.OrderBy(vs => vs.Descrizione).ToListAsync();
VoceCorrente = Voci.FirstOrDefault(vs => vs.VoceSpesaNo == Item.VoceSpesaNo);
在属性的设置器中有对 RaisePropertyChanged 的调用
【问题讨论】:
-
显示您正在使用的代码。如果你想选择一个特定的值,每一个都应该工作(前提是你有正确的代码可以使用所选的方法进行选择)
标签: c# visual-studio uwp template10