【发布时间】:2016-09-16 08:30:07
【问题描述】:
我遇到了一个奇怪的问题: 当我在 AppBarButton-Flyout 中包含一个 ListBox 时:
<Page.TopAppBar>
<CommandBar>
<AppBarButton Icon="Add">
<AppBarButton.Flyout>
<Flyout x:Name="TestFlyout">
<ListBox>
<ListBoxItem Content="A" />
<ListBoxItem Content="C" />
<ListBoxItem Content="D" />
<ListBoxItem Content="e" />
<ListBoxItem Content="F" />
<ListBoxItem Content="A" />
</ListBox>
</Flyout>
</AppBarButton.Flyout>
</AppBarButton>
</CommandBar>
</Page.TopAppBar>
项目未被选中(它们应该以蓝色突出显示)。 Button Flyout 中的相同列表框正在工作:
<Button Content="Click me" IsEnabled="True">
<Button.Flyout>
<Flyout>
<ListBox>
<ListBoxItem Content="A" />
<ListBoxItem Content="C" />
<ListBoxItem Content="D" />
<ListBoxItem Content="e" />
<ListBoxItem Content="F" />
<ListBoxItem Content="A" />
</ListBox>
</Flyout>
</Button.Flyout>
</Button>
起初我认为这可能是图形问题,但我尝试将SelectedItem 属性绑定到setter。但是 setter 永远不会被调用。
我只是在这里找不到我的错误。
编辑:
似乎是我的机器的问题。在其他 Windows-10 上,它就像一个魅力。
【问题讨论】:
-
它适用于我的桌面(-> 我可以选择任何项目,并且所选项目以蓝色突出显示...)。您是否在一个普通的新 XAML 页面中尝试过?
-
@gregkalapos:我为此创建了一个空白的新应用。
-
好的,我现在也在你的 gif 上看到了。对我来说,他们被选中了......(在这两种情况下,它们对我来说都是蓝色的)你可以上传你的视觉工作室解决方案吗?
-
@gregkalapos:谢谢,在另一台机器上试过,同样的应用程序正在运行。似乎是我的设备的问题。
-
很高兴听到! ...这也是我最初的想法...