<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<SplitView x:Name="mySplitView" DisplayMode="CompactInline" IsPaneOpen="False"
CompactPaneLength="50" OpenPaneLength="150" Content="{Binding}"> // using PaneBackground I can set color statically
<SplitView.Pane>
<StackPanel>
<Button x:Name="HamburgerButton" FontFamily="Segoe MDL2 Assets" Content=""
Width="50" Height="50" Background="Transparent" Foreground="White" Click="HamburgerButton_Click" />
<StackPanel>
</SplitView.Pane>
</SplitView>
</Grid>
。如何动态更改Splitview窗格的颜色,即如果用户单击按钮将颜色更改为黄色它应该更改,如果用户想要默认的强调颜色,那么应该像在Outlook Mail应用程序中那样设置。我在一个页面中有我的分割视图,并希望其他xaml页面中的按钮即设置页面。
答案 0 :(得分:3)
您可以使用'PaneBackground'属性为代码,并在每个项目点击事件处理程序中使用此代码:
<VirtualHost *:80>
ServerName laravelht.vn
DocumentRoot D:/Lavarel/HTPortal/public
SetEnv APPLICATION_ENV "development"
<Directory D:/Lavarel/HTPortal/public>
DirectoryIndex index.php
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
这是你尝试做的吗?
答案 1 :(得分:1)
也许你可以使用这个主题。
1.在App.xmal文件中,您需要添加两个主题资源
<Application
x:Class="App3.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App3"
RequestedTheme="Light">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush">#FFDEDEDE</SolidColorBrush>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush">Yellow</SolidColorBrush>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
2.更改MainPage的代码
public MainPage()
{
this.InitializeComponent();
RequestedTheme=ElementTheme.Light;
}
private void HamburgerButton_Click(object sender, RoutedEventArgs e)
{
RequestedTheme = ElementTheme.Dark;
}
它应该在winrt中工作。
答案 2 :(得分:0)
以下内容可满足您的要求:
设置页面上的按钮,负责更改其他页面中拆分视图的颜色。新颜色可以保存到应用程序的本地设置中。
public sealed partial class SettingPage : Page
{
public SettingPage()
{
this.InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ApplicationDataContainer localsettings = ApplicationData.Current.LocalSettings;
localsettings.Values["SplitViewColoronShell"] = Colors.Yellow.ToString();
}
}
在shell页面后面的代码中,从本地设置中获取颜色并将其设置为splitview。
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
ApplicationDataContainer localsettings = ApplicationData.Current.LocalSettings;
if (localsettings.Values["SplitViewColoronShell"] != null)
{
mySplitView.PaneBackground = GetSolidColorBrush(localsettings.Values["SplitViewColoronShell"].ToString());
}
}
public SolidColorBrush GetSolidColorBrush(string hex)
{
hex = hex.Replace("#", string.Empty);
byte a = (byte)(Convert.ToUInt32(hex.Substring(0, 2), 16));
byte r = (byte)(Convert.ToUInt32(hex.Substring(2, 2), 16));
byte g = (byte)(Convert.ToUInt32(hex.Substring(4, 2), 16));
byte b = (byte)(Convert.ToUInt32(hex.Substring(6, 2), 16));
SolidColorBrush myBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(a, r, g, b));
return myBrush;
}