[英]UWP Set NavigationView TogglePaneButton color
As you can see from the image, the TogglePaneButton
has a distinct color from the remaining. 从图像中可以看到,
TogglePaneButton
具有与其余颜色不同的颜色。
That's because I set it manually to WhiteSmoke
(actually in my pushed code it's already gray) when it is in the LeftMinimal
mode in its source code of VisualState
Compact. 那是因为当它在
VisualState
Compact的源代码中处于LeftMinimal
模式时,我将其手动设置为WhiteSmoke
(实际上在我推送的代码中已经是灰色)。
I thought I could change it back when pane is open by modifying its visual state like this: 我以为可以通过以下方式修改其可视状态来将其重新打开:
<VisualState x:Name="Expanded">
<VisualState.Setters>
<Setter Target="RootSplitView.PaneBackground" Value="{ThemeResource MainNavigationViewBackground}" />
<Setter Target="TogglePaneButton.Background" Value="{ThemeResource MainNavigationViewBackground}" />
</VisualState.Setters>
</VisualState>
But it is not working. 但这是行不通的。 How can I achieve that?
我该如何实现?
The code has exceeded 30000 characters so I can only post the link: 该代码已超过30000个字符,因此我只能发布链接:
https://github.com/SeakyLuo/SMPlayer/blob/master/SMPlayer/Dictionaries/MainNavigationView.xaml https://github.com/SeakyLuo/SMPlayer/blob/master/SMPlayer/Dictionaries/MainNavigationView.xaml
The problem here is that the VisualStates
react to the different types of the pane modes, but do not react to the open/closed event. 这里的问题是
VisualStates
对窗格类型的不同类型作出反应,但对open / closed事件不作出反应。
I would recommend giving the button itself a Transparent
background and just displaying a colored Border
under the button and pane. 我建议给按钮本身一个
Transparent
背景,并在按钮和窗格下仅显示一个彩色的Border
。 When the pane will be closed and in minimal mode, the border under the button will make it look as if the button had the right background color. 当窗格关闭并处于最小模式时,按钮下方的边框将使其看起来好像按钮具有正确的背景色。 When the pane opens, it will be drawn above the
Border
, and the button will have the same background as the pane. 窗格打开时,它将绘制在
Border
上方 ,并且按钮的背景与窗格相同。
I have found a very simple solution: 我找到了一个非常简单的解决方案:
Just make another TogglePaneButton
and put it over the original one. 只需制作另一个
TogglePaneButton
并将其放在原始TogglePaneButton
。 Then let it work as the real one. 然后让它成为真正的作品。 Set its visibility to
Collapsed
when needed. 需要时将其可见性设置为“已
Collapsed
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.