Width of control which has combobox set to window's width wpf - 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}" />

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>

WPF DataGrid Vertical Line Thickness

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>

WPF ComboBox with custom dropdown width

How can I extend width of dropdown of a combo, like Run dialog:
Popup is a part of ComboBox template ("PART_Popup"). Add a Style for Popup to combobox Resources and set appropriate width there.
<ComboBox>
<ComboBox.Resources>
<Style TargetType="Popup">
<Setter Property="Width" Value="1000"/>
</Style>
</ComboBox.Resources>
</ComboBox>
note also that there is a binding for Popup.MinWidth in template so you can't make it too small.

how to set List item Height,width and Border for ListBox in wpf

I need to set Height,Width and Border Color for Each list items in the Listbox. In the event that I set Setter Property
it's setting for entire listbox. Be that as it may, I need to set every last rundown thing. Any one help me.
here's my code:
<ListBox x:Name="lbOne" PreviewMouseLeftButtonDown="ListBox_PreviewMouseLeftButtonDown"
HorizontalAlignment="Left" Margin="12,29,0,12" Width="215"
ScrollViewer.VerticalScrollBarVisibility="Visible" />
Try the following piece of code and let me know if it works for you.
<ListBox ...>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListBox.ItemContainerStyle>
Also, please refer the followings link for reference.
Stretch ListBox Items hit area to full width of the ListBox? ListBox style is set implicity through a theme
Silverlight 3: ListBox DataTemplate HorizontalAlignment
Probably, refer to the below link for using the ListBox Item properties appropriately.
http://msdn.microsoft.com/en-us/library/cc278062(v=vs.95).aspx

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