无法使用 Mahapp 更改树视图的背景颜色
Can't change background color of treeview use Mahapp
我尝试更改 treeview 的颜色,但颜色无法填满整个 treeview
总是这样:
我的.xaml
<Grid >
<TreeView x:Name="treeView"
BorderThickness="0"
Style="{x:Null}"
Height="Auto" Width="Auto"
Background="#38364E"
Foreground="#38364E"
Margin="15,15,15,15">
</TreeView>
</Grid>
我的App.xaml
<Application x:Class="Rodemeyer.Dot2Wpf.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml" DispatcherUnhandledException="Application_DispatcherUnhandledException" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" d1p1:Ignorable="d" xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml">
</ResourceDictionary>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml">
</ResourceDictionary>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml">
</ResourceDictionary>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml">
</ResourceDictionary>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml">
</ResourceDictionary>
<ResourceDictionary Source="ResourcesDictionary/ButtonStyle.xaml">
<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" xmlns:vm="clr-namespace:Rodemeyer.Dot2Wpf.ViewModel" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
我猜treeview使用的是mahapp的颜色样式,它不能手动改变背景颜色。
有没有人知道在使用mahapp框架时如何给treeview填充颜色。
您可以通过覆盖模板中使用的一些资源来更改颜色,例如:
<TreeView x:Name="treeView"
BorderThickness="0"
Height="Auto" Width="Auto"
Margin="15,15,15,15">
<TreeView.Resources>
<SolidColorBrush x:Key="MahApps.Brushes.ThemeBackground" Color="#38364E" />
<SolidColorBrush x:Key="MahApps.Brushes.Text" Color="Red" />
<!-- mouse over: -->
<SolidColorBrush x:Key="MahApps.Brushes.Accent3" Color="Green" />
<!-- selection: -->
<SolidColorBrush x:Key="MahApps.Brushes.Accent" Color="Orange" />
</TreeView.Resources>
</TreeView>
我尝试更改 treeview 的颜色,但颜色无法填满整个 treeview
总是这样:
我的.xaml
<Grid >
<TreeView x:Name="treeView"
BorderThickness="0"
Style="{x:Null}"
Height="Auto" Width="Auto"
Background="#38364E"
Foreground="#38364E"
Margin="15,15,15,15">
</TreeView>
</Grid>
我的App.xaml
<Application x:Class="Rodemeyer.Dot2Wpf.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml" DispatcherUnhandledException="Application_DispatcherUnhandledException" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" d1p1:Ignorable="d" xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml">
</ResourceDictionary>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml">
</ResourceDictionary>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml">
</ResourceDictionary>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml">
</ResourceDictionary>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml">
</ResourceDictionary>
<ResourceDictionary Source="ResourcesDictionary/ButtonStyle.xaml">
<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" xmlns:vm="clr-namespace:Rodemeyer.Dot2Wpf.ViewModel" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
我猜treeview使用的是mahapp的颜色样式,它不能手动改变背景颜色。
有没有人知道在使用mahapp框架时如何给treeview填充颜色。
您可以通过覆盖模板中使用的一些资源来更改颜色,例如:
<TreeView x:Name="treeView"
BorderThickness="0"
Height="Auto" Width="Auto"
Margin="15,15,15,15">
<TreeView.Resources>
<SolidColorBrush x:Key="MahApps.Brushes.ThemeBackground" Color="#38364E" />
<SolidColorBrush x:Key="MahApps.Brushes.Text" Color="Red" />
<!-- mouse over: -->
<SolidColorBrush x:Key="MahApps.Brushes.Accent3" Color="Green" />
<!-- selection: -->
<SolidColorBrush x:Key="MahApps.Brushes.Accent" Color="Orange" />
</TreeView.Resources>
</TreeView>