我希望避免在Listbox
中加载应用程序时默认发生的第一项选择。我试着用
SelectedIndex= -1
但它并没有起作用。在用户从Listbox
中选择任何项之前,我不希望在加载ListBox
时选择任何项。我将IsSynchronization
设置为true,但将其设为false
也不能解决我的问题。尽管我必须始终将IsSychronization
设置为true
。但这也没关系。我用谷歌搜索了一下,但找不到任何相关的答案。
有人能告诉我怎么做吗?
发布于 2014-11-27 01:02:06
这事发生在我身上。当我将ListBox.ItemsSource
直接绑定到视图模型中的集合时,默认情况下没有选择re。
当我切换到使用CollectionViewSource
作为ListBox.ItemsSource
时,突然在默认情况下选择了第一项。
事实证明这要归功于ListBox.IsSynchronizedWithCurrentItem
。将其设置为
IsSynchronizedWithCurrentItem="False"
在ListBox
上,恢复了默认情况下不选择任何内容的所需行为。
发布于 2013-01-10 20:55:06
将IsEnabled绑定到一个布尔值,该布尔值将在用户可以选择时进行标记。列表框仍然可见,但不可选。这是我使用的一个标签的样式代码,它必须在登录期间启用,但不能在操作停止后启用。
<Style x:Key="LabelStyle" TargetType="{x:Type Label}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Width" Value="70" />
<Setter Property="Height" Value="28"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=LoginInProcess}" Value="True">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=LoginInProcess}" Value="False">
<Setter Property="IsEnabled" Value="True" />
</DataTrigger>
</Style.Triggers>
</Style>
https://stackoverflow.com/questions/14257928
复制相似问题