I'm trying to change the color of each part of the scrollbar for ScrollViewer, ListView, and RichTextBox using XAML.
This works as a global override for all Scrollbar Backgrounds.
<Style TargetType="{x:Type ScrollBar}">
<Setter Property="Background" Value="#FF191919"/>
<Setter Property="BorderBrush" Value="#FF191919"/>
</Style>
But I need a style color for each part.
ScrollBar
Thumb
RepeatButton
Using Style TargetType doesn't work for any other part.
The Thumb and RepeatButtons stay default white/gray.
Related
I am trying to change the background color of the MaterialDesign ListBoxItem style but I can't get it to work.
I know about overriding the style like this :
<Style x:Key="MaterialDesignListBoxItem"
TargetType="ListBoxItem"
BasedOn="{StaticResource MaterialDesignListBoxItem}">
</Style>
But I won't get the MaterialDesign animations as it will just be a regular button.
Is there any way to change the background color and keep the MaterialDesign look and feel?
Set the ItemContainerStyle property of the ListBox to a custom Style that is based on MaterialDesignListBoxItem, e.g.:
<ListBox>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MaterialDesignListBoxItem}">
<Setter Property="Background" Value="Green" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
i am new in WPF. My project have one Grid Control that grid control border is Red color and I have a one button. when i click the button grid border color will be changed to green.
How can i changed to border color using control template with DataTemplate trigger. My Goal is border color will be change using template(don't change programmatically)
Screenshot will be attached.enter image description here
You can create a property called for example IsColorChanged and bind to your DataTrigger and when button is clicked set this boolean typed property to true on the code side then DataTrigger will set to background property of your border to the green.
<Grid>
<Border BorderThickness="2" CornerRadius="4">
<Border.Style>
<Style TargetType="{x:Type Border}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsColorChanged}" Value="True">
<Setter Property="Background" Value="Green"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
</Border>
</Grid>
I'm maintaining a big old C#/WPF application in which a style has been set globally for all buttons It can sound ugly, but I can't change this without refactoring the whole app.
Here is an extract of this style:
<Style TargetType="Button">
<Setter Property="Height" Value="32"/>
<Setter Property="MinWidth" Value="96"/>
<Setter Property="Margin" Value="10"/>
</Style>
The problem is that when I want to use a DatePicker, this global style influenced the appearance of the DataPicker:
Is there a simple way to restore the default Margin, Height and MinWidth only for the Button inside the DatePicker?
You can override the Style for the Buttons locally. The following XAML sets the Style for all Buttons inside the DatePicker back to the default Style.
<DatePicker>
<DatePicker.Resources>
<!-- Default Style -->
<Style TargetType="{x:Type Button}"/>
</DatePicker.Resources>
</DatePicker>
Edit
As requested in the comments, a Style to fix this issue globally
<Style TargetType="{x:Type DatePicker}">
<Style.Resources>
<Style TargetType="{x:Type Button}"/>
</Style.Resources>
</Style>
Note: This Style should be placed in the same hierarchy-context as the Button Style.
I've added a DataGrid to my WPF Window, and I've set the VerticalGridLinesBrush property in the XAML to show the vertical grid lines in the relevant colour. But I can't figure out how to increase width of the vertical grid lines, that are displayed in the DataGridRow.
Can someone please show me how to set the vertical grid line thickness in a WPF DataGrid?
set this properties
GridLinesVisibility="All" , VerticalGridLinesBrush="Red" and BorderThickness="1,1,5,0"
in dataGrid.
It seems there is no thickness setting for the GridLines... you can probably use DataGridCell properties instead.
<DataGrid GridLinesVisibility="Horizontal">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness" Value="0,0,3,0"/>
<Setter Property="BorderBrush" Value="Red"/>
</Style>
</DataGrid.CellStyle>
How do I change the font size of the tabs when using the MahApps.Metro AnimatedSingleRowTabControl.
When using a normal TabControl, my theme TabItem (based on MetroTabItem) overrides the fontsize but this does not work for the animated single row tab control. I tried setting the fontsize property on the control in the XAML and this didn't work either.
Regards
Alan
You can also define the following in the Application.Resources your App.xaml:
<system:Double x:Key="TabItemFontSize">16</system:Double>
Controls.TabControl.xaml makes use of it as follows:
<Setter Property="Controls:ControlsHelper.HeaderFontSize"
Value="{DynamicResource TabItemFontSize}" />
You can do the following, setting the header font size to whatever value you want:
<metro:MetroAnimatedSingleRowTabControl>
<metro:MetroAnimatedSingleRowTabControl.ItemContainerStyle>
<Style TargetType="{x:Type metro:MetroTabItem}" BasedOn="{StaticResource {x:Type metro:MetroTabItem}}">
<Setter Property="HeaderFontSize" Value="24"/>
</Style>
</metro:MetroAnimatedSingleRowTabControl.ItemContainerStyle>
</metro:MetroAnimatedSingleRowTabControl>