WPF DataGrid Vertical Line Thickness - wpf

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>

Related

Need to change border color in grid using control template and data trigger in WPF

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>

Change Global Scrollbar Color with XAML

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.

DataGridCell BorderBrush not working

I tried to set DataGridCell BorderBrush, but it looks like there is some other setting, which also sets border between cells.
Current Style:
<Style x:Key="DataGridCellStyle1" TargetType="{x:Type DataGridCell}">
<Setter Property="BorderBrush" Value="Yellow"/>
</Style>
It looks like this:
I don't want that black border there. I want just the yellow border. Can someone please point me, where can I set the "black" border?
DataGrid has additional properties for grid lines
try set Yellow color for both
VerticalGridLinesBrush="Yellow"
HorizontalGridLinesBrush="Yellow"
or hide them
GridLinesVisibility="None"

Width of control which has combobox set to window's width wpf

I have a control which has a combobox and this control is placed in a window. When I click on the dropdown of the combobox the width of the items are going out of the width of the window.
The width of the combobox in the control are set as minwidth=600 and maxwidth = 600.
If I change the width here, all the places where this control is used, its width will be affected.
Can someone help me?
You can specify the dropdown width (and other properties ... MaxWidth) by defining a ComboBoxItem style and setting your ComboBox ItemContainerStyle to it.
<Style x:Key="ComboBoxItemStyle" TargetType="{x:Type ComboBoxItem}">
<Setter Property="Height" Value="25"/>
<Setter Property="Width" Value="600"/>
</Style>
<ComboBox ItemContainerStyle="{StaticResource ComboBoxItemStyle}" />

WPF: Remove dotted border around focused item in styled listbox

I have a horizontal listbox with a custom controlIemplate. The selected item gets a dotted frame when focused. Anyone know how to get rid of it?
You need to set FocusVisualStyle of each ListBoxItem to null. Steps are bellow
1) Create ItemContainerStyle for the ListBox
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/> ....
2) Set that style to Listbox
<ListBox ItemContainerStyle="{DynamicResource ListBoxItemStyle1}"

Resources