[英]How to create a Button's Template with ContentPresenter's content having distinct Foregrounds that can be changed by the Button's VisualState
[英]Button's have limited PointerOver VisualState in NavigationView Header
我正在處理我的 UWP 項目,當我在 NavigationView Header 模板中放置一個按鈕時,當鼠標位於底部 5 個像素左右時,它只有 PointerOver VisualState,如下所示。 點代表我的鼠標在標題中的按鈕上的位置。
下面是我的簡單代碼。
<NavigationView x:Name="NavigationView" Header="" SelectionChanged="{x:Bind mainViewModel.selectionChanged, Mode=OneWay}" Background="{ThemeResource SystemControlAltHighAcrylicWindowBrush}">
<NavigationView.HeaderTemplate>
<DataTemplate>
<StackPanel Visibility="{Binding listsClicked}">
<Button Content="Food"/>
</StackPanel>
如果我將 CommandBar 放在標題中,則會出現同樣的問題。 我怎樣才能允許 Button 的整個字段的 PointerOver VisualState?
事實上,你的指針並沒有移動到按鈕上,而是被標題欄擋住了。
它們之間的關系如下圖所示。
這樣做的原因是你使用了
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
但是標題欄不是隱藏的,它是透明的。 它仍然保持原樣,位於所有元素的頂部。
您有兩種方法可以解決此問題。
Window.Current.SetTitleBar(ele)
指定一個元素作為標題欄,使其具有標題欄的特性,同時避免元素被遮擋。此致。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.