I've followed this question to get rid of the highlight effect in my ListView. The highlight effect is disabled correctly, but I'm still getting a magnify effect on the MouseOver. It's very anoying especially when moving over the ListView because it give a blury effect.
Here is my code
<ListView ItemsSource="{Binding Roles}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Focusable" Value="False"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Focusable" Value="False" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
</ListView>
And this:
is the behavior I'm willing to get rid off.
Does anyone know how to get rid of this magnify effect?
rather than changing border thickness
<Setter Property="BorderThickness" Value="0" />
hide it by changing border color
<Setter Property="BorderBrush" Value="{x:Null}" />
Related
I want to find a way to highlight my data grid rows when I hover over them. The closest thing I found was adding a border to the datagrid row. However, in doing so it causes the row I am hovering over to shift to the right, slightly. On top of that it shows a horizontal scrollbar to appears at the bottom.
this is what I'm doing to the datagrid
<Style x:Key="DefaultRowStyle" TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="LightSlateGray" />
<Setter Property="BorderThickness" Value="2" />
</Trigger>
</Style.Triggers>
</Style>
My question is this: is there another way to highlight the datagrid row?
This is due to the element resizing when a border is added to it. The easiest option is to add a permanent border and make it visible or transparent.
<Style x:Key="DefaultRowStyle" TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="2" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="LightSlateGray" />
</Trigger>
</Style.Triggers>
</Style>
I snooped the desired property and I can change it in real-time:
But I don't know what exactly to set in the code.
When I edit the XAML like this:
<dock:DockingManager x:Name="dockManager" ...>
...
<dock:DockingManager.AnchorablePaneControlStyle>
<Style TargetType="{x:Type dock:LayoutAnchorablePaneControl}">
<Setter Property="BorderBrush" Value="DarkRed"/>
</Style>
</dock:DockingManager.AnchorablePaneControlStyle>
...
I get the border color changed but the rest of behavior is unusable:
I am not get the big picture yet for what you wanna get, but I think you have to edit the Theme.xaml file containing all AvalonDock Styles and have a look there at the following style:
<Style x:Key="AvalonDock_AnchorablePaneControlStyle" TargetType="{x:Type avalonDockControls:LayoutAnchorablePaneControl}">
<Setter Property="TabStripPlacement" Value="Bottom" />
<Setter Property="Padding" Value="0" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="{Binding Model.Root.Manager.Foreground, RelativeSource={RelativeSource Self}}" />
<Setter Property="Background" Value="{DynamicResource AvalonDock_BaseColor8}" />
<Setter Property="Template">...
Then you can see that the Background property is binded to a DynamicResource. You have to change the value of AvalonDock_BaseColor8 resource accordingly to what you want to achieve.
Trying to restyle a WPF datagrid. Almost where I need to be, except for one peculiarity: when selecting a row, the contents of all the cells are surrounded by a white border.
I'm at a loss as to how to get rid of this. At the moment, my styling looks like this:
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#3CACDC" />
<Setter Property="Foreground" Value="White" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#90C8E0" />
</Trigger>
</Style.Triggers>
</Style>
Plus DataGridCell has an almost identical style set.
It's not clear whether the question How to suppress DataGrid cell selection border? is asking the same question, but the accepted solution of setting FocusVisualStyle to Null doesn't remove the border. It does, however, change the style:
How can I get ride of that border?
I think you can try styling DataGridCell style
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
</Style>
</DataGrid.CellStyle>
I have run into a few issues with gridcontrol.
I have to style and format a grid column with padding,colors,fonts and hover effects.
<Style x:Key="SelectedRowStyle" TargetType="{x:Type dxg:RowControl}">
<Setter Property="Foreground" Value="Black" />
<Setter Property="FontFamily" Value="pack://application:,,,/PA.Tos.UI;component/ResourceDictionaries/#Brandon Grotesque Black" />
<Setter Property="FontSize" Value="12" />
<Setter Property="FontWeight" Value="Regular" />
<Style.Triggers>
<DataTrigger Binding="{Binding
ElementName=GroupCodeListView,Path=DataContext.SelectedGroupCode.Deleted,
UpdateSourceTrigger=PropertyChanged}" Value="true">
<Setter Property="Background" Value="Red" />
<Setter Property="Foreground" Value="Black" />
</DataTrigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{StaticResource HoverRowBorderColor}" />
<Setter Property="Foreground" Value="Black" />
</Trigger>
<Trigger Property="dxg:GridViewBase.IsFocusedRow" Value="True">
<Setter Property="Background" Value="{StaticResource HoverRowBorderColor}" />
<Setter Property="BorderBrush" Value="{StaticResource HoverStrokeColor}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Foreground" Value="Black" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="CustomCellStyle" BasedOn="{StaticResource {dxgt:GridRowThemeKey
ResourceKey=LightweightCellStyle}}" TargetType="{x:Type dxg:LightweightCellEditor}">
<Setter Property="MaxHeight" Value="25"/>
<Setter Property="MinHeight" Value="25"/>
<Style.Triggers>
</Style.Triggers>
In response to a mouse hover or row selection, i have to set the border blue across all grid lines. Only the bottom grid line is blue as of
now from the above. Code applicable to cellcontent presenter won't be possible here.
In response to a trash icon clicked, i have to display light red background for the particular row.
I bind (viewmodel property)SelectedGroupCode.Deleted=true to the background.The binding is shown in the code.
but all rows are painted red except the row in question.
The grid lines width has to be set. i have managed to set it for the horizontal lines only using gridrowthemekey_rowcontrolcontainertemplate.
I assure you i have read through some previous threads but its taking too much time for a scrum sprint.
What is missing?
If you want to change the cell style in response to a mouse hover then you can use RelativeSource markup extension in DataTrigger's binding. If you want to check whether the row is focused, then you can use RowData.IsFocused property.
Here is example:
<Style x:Key="CustomCellStyle" TargetType="{x:Type dxg:LightweightCellEditor}" BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=LightweightCellStyle}}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType={x:Type dxg:RowControl}}}" Value="True">
<Setter Property="BorderBrush" Value="Blue" />
</DataTrigger>
<DataTrigger Binding="{Binding RowData.IsFocused}" Value="true">
<Setter Property="BorderBrush" Value="Blue" />
</DataTrigger>
</Style.Triggers>
</Style>
For displaying custom style for particular row I suggest you to use Conditional Formatting.
Here is example:
<dxg:GridControl ...>
...
<dxg:GridControl.View>
<dxg:TableView>
<dxg:TableView.FormatConditions>
<dxg:FormatCondition Expression="[Deleted]" FieldName="Profit">
<dxc:Format Foreground="Red"/>
</dxg:FormatCondition>
</dxg:TableView.FormatConditions>
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
I Had a Tabcontrol
and a RichTextBox control as below
<TabControl x:Name="tabControl" SelectedIndex="{Binding SelectedTabIndex, Mode=TwoWay}">
<TabItem Header="Edit" TabIndex="0" />
<TabItem Header="View" TabIndex="1" />
</TabControl>
<RichTextBox x:Name="richTextBox"> </RichTextBox>
and now I have two Styles defined like
<Style TargetType="Table" x:Key="EditStyleKey">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="1"/>
</Style>
<Style TargetType="Table" x:Key="ViewStyleKey">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="0"/>
</Style>
I will create a table in Rich text box.
My problem is that when I select the first tabitem (SelectedIndex=0) then I should apply trigger to change the style "EditKeyStyle" for table in richtextbox. and when I select the second tab (SelectedIndex=1) then I should apply the "ViewStyleKey" for Richtextbox.
As I am new to WPF I couldn't able to fix it using the trigger and I am not sure of where to write the trigger for these kind of dependency.
Someone please provide me help for fixing this issue as this is a high priority issue.
Thanks in advance.
Consider using a single Style with Style.Triggers and DataTriggers to control the style of the table in your RichTextBox. The code below changes the BroderThickness and Padding properties based on the value of the SelectedIndex you'll have to change the SelectedIndex binding so that it points to your TabControl.SelectedIndex property.
I've used something similar to the code below in a project
<UserControl.Resources>
<Style x:Key="tableStyleKey" TargetType="Table" >
<Setter Property="BorderBrush" Value="Black"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=SelectedIndex}" Value="0">
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="1"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=SelectedIndex}" Value="1">
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="1"/>
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<RichTextBox>
<Table Style="{StaticResource tableStyleKey}"/>
</RichTextBox>