Ok i'm trying to style the datepicker from microsoft from their wpftoolkit.dll. I have it in a grid that is disabled, unfortunately it's background color stays white(despite it being disabled) unlike the other controls that gray out.
Ok I did do this:
<Style TargetType="{x:Type tk:DatePicker}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="LightGray"/>
</Trigger>
</Style.Triggers>
</Style>
But the text inside it that displays "Show Calendar" still has a white background. How do I set a style to make it look like the other controls i.e. gray out all of the background?
The background of the "Show Calendar" text (the part of the control that shows the currently selected date) is a "DatePickerTextBox" that's sitting inside the date picker. To set its background, use:
<Style TargetType="{x:Type tk:DatePickerTextBox}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="LightGray"/>
</Trigger>
</Style.Triggers>
</Style>
Related
I have a custom style that I'm applying to a TreeViewItem, based on the MaterialDesignTreeViewItem style :
<Style x:Key="Header" TargetType="TreeViewItem" BasedOn="{StaticResource MaterialDesignTreeViewItem}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="Red"/>
</Trigger>
</Style.Triggers>
<Setter Property="FontSize" Value="22"/>
</Style>
Now the problem is that when I click on a TreeViewItem, the background goes red and the foreground goes white, but the dropdown arrow (which is not included in the red background) switches to white as well, so we can't see it anymore (background of my app is white)
Is it possible to change the foreground without changing the arrow's color ?
I'm using the Extended WPF Toolkit's IntegerUpDown control.
I was able to stylize the arrow buttons in a previous question.
Before
After
I've run into some additional style problems:
I'm using PresentationFramework.Aero and Aero2.
<!-- RepeatButton Style -->
<Style x:Key="{x:Static theme:ResourceKeys.SpinnerButtonStyleKey}" TargetType="RepeatButton">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="DarkBlue"/>
<Setter Property="BorderBrush" Value="Transparent" />
</Trigger>
</Style.Triggers>
</Style>
Link to the full XAML: http://pastebin.com/ETYgHEpz
The IsEnabled False Trigger will not override the Disabled Background or Border Color. It always stays White, I need it Transparent. However I can override the Opacity and BorderThickness. (Windows 10):
Cannot change the IsMouseOver Background Color, always Light Blue. (Windows 10):
Windows 7 always displays a White Border, even if BorderThickeness is 0 and Color is Transparent or {x:Null}:
I think it is being overriden by a Control Template, but IntergerUpDown doesn't have a RepeatButton Style within the Control Template and I've had trouble trying to add one. I had to create the Style outside.
some properties won't work when you set via Style setters. This is because of Dependency Property Value Precedence. Try changing the values in ControlTemplate triggers.
I'm using wpf and I've listview.
Everything just works fine, but I want to disable focusing on header (when i enter header with mouse it changes color to blue).
I mean this
This will do the work.
<GridView.ColumnHeaderContainerStyle>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="IsEnabled" Value="False"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
</GridView.ColumnHeaderContainerStyle>
I have 4 colored radio buttons that are styled like toggle buttons by using
BasedOn="{StaticResource {x:Type ToggleButton}}"
The default styling is when a color is selected, it will change the background color to white. I want to change that so that instead it will give it a yellow border around the color. Any ideas how to do this?
I've tried something like this, but it doesn't seem to affect the buttons:
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="BorderBrush" Value="Yellow"/>
<Setter Property="BorderThickness" Value="5"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
Instead of IsChecked you should use HasContent:
<Trigger Property="HasContent" Value="true">
<Setter Property="FocusVisualStyle" Value="{StaticResource CheckRadioFocusVisual}"/>
<Setter Property="Padding" Value="4,0,0,0"/>
</Trigger>
This is the snippet from the default template, try changing it with the one you like.
I got something working here:
With your settings:
Good Luck
I'm changing the look of all ComboBoxes in my application by adding this Style to App.xaml:
<Style TargetType="ComboBox">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="#303030"/>
<Setter Property="BorderBrush" Value="#000000"/>
</Style>
There are two colors that I haven't been able to set:
1) the Background color whenIsEnabled=false
2) the highlight Background color when the mouse is over the ComboBox.
How can I change these two colors?
[edit: it looks like the highlight color is not the same as the mouse over color, because when I move my mouse over the ComboBox it will briefly turn the color I defined as the mouse over color, and then turn into some other color (light blue)]
You want to check Style Triggers . Also need to override the ItemContainerStyle to get rid of the default light blue selection color
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="SomeColor" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" Value="SomeOtherColor" />
</Trigger>
</Style.Triggers>