C# UWP:在AppBarButton弹出按钮中未选中列表框项目
我遇到了一个奇怪的问题: 当AppBarButton弹出按钮中包含列表框时:C# UWP:在AppBarButton弹出按钮中未选中列表框项目,c#,listbox,uwp,C#,Listbox,Uwp,我遇到了一个奇怪的问题: 当AppBarButton弹出按钮中包含列表框时: <Page.TopAppBar> <CommandBar> <AppBarButton Icon="Add"> <AppBarButton.Flyout> <Flyout x:Name="TestFlyout">
<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>
编辑:
似乎是我的机器出了问题。在其他Windows-10上,它工作得很好。将AppBarButton上的AllowFocusOnInteraction
属性设置为true
XAML解决方案(适用于Windows 10,版本1607)
您还可以将其包装为附加属性,即使在所有Windows 10版本上,该属性也可以在XAML中使用
更多信息
您在Windows 10周年更新(1607)上遇到了一项新功能,即build 14393
这对于大多数应用程序栏的使用来说是一种改进,但会干扰您的应用程序,因此当您将构建更改为14393而不是10586时,您需要覆盖默认值
这里有一篇博文。它还包含附加的属性实现。它在桌面上对我有效(->我可以选择任何项目,所选项目以蓝色突出显示…)。你在一个普通的新XAML页面上尝试过吗?@gregkalapos:我已经为这个创建了一个空白的新应用程序。好的,我现在也在你的gif上看到了它。对我来说,他们被选中了。。。(在这两种情况下,它们对我来说都是蓝色的)你可以上传你的visual studio解决方案吗?@gregkalapos:谢谢,在不同的机器上试用过,并且相同的应用程序正在工作。似乎是我的设备有问题。很高兴听到。。。这也是我最初的想法。。。
<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>
<AppBarButton x:Name="myAppBarButton"
AllowFocusOnInteraction="True">
...
</AppBarButton>
if (Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.UI.Xaml.FrameworkElement", "AllowFocusOnInteraction"))
myAppBarButton.AllowFocusOnInteraction = true;