ListView.GridViewColumn (*) width

Please try that solution: <ListView> <ListView.View> <GridView> <GridViewColumn Header=”column1″ x:Name=”col1″/> <!–Column that shall resize: Width is set to the Actual Width of the helper field defined below–> <GridViewColumn Header=”column2″ Width=”{Binding ElementName=helperField, Path=ActualWidth}”/> </GridView> </ListView.View> Test Text </ListView> <!–This is the hidden helper Grid which does the resizing –> <Grid Visibility=”Hidden”> <Grid.ColumnDefinitions> <!–Width is bound to … Read more

Mouse scroll not working in a scroll viewer with a wpf datagrid and additional UI elements

I think Dave’s solution is a good one. However, one recommendation I’d make is to catch the PreviewMouseWheel event on the scrollviewer instead of on the datagrid. If you don’t, you might notice some minor differences based on whether you’re scrolling over the datagrid or the scroll bar itself. The reasoning is that the scrollviewer … Read more

wpf: DataGrid disable selected row styles – or row selecting

figured out the XAML to get rid of selection style.. not ideal, but close enough.. <Style x:Key=”CellStyle” TargetType=”{x:Type DataGridCell}”> <Setter Property=”Foreground” Value=”Black” /> <Style.Triggers> <Trigger Property=”IsSelected” Value=”True”> <Setter Property=”Background” Value=”{x:Null}” /> <Setter Property=”BorderBrush” Value=”{x:Null}” /> </Trigger> </Style.Triggers> </Style>

wpf datagrid alternate row coloring

Finally, this is what I ended up with for generically setting alternate row colors. <Style TargetType=”{x:Type DataGrid}”> <Setter Property=”Background” Value=”#FFF” /> <Setter Property=”AlternationCount” Value=”2″ /> </Style> <Style TargetType=”{x:Type DataGridRow}”> <Style.Triggers> <Trigger Property=”ItemsControl.AlternationIndex” Value=”0″> <Setter Property=”Background” Value=”#CCC”></Setter> </Trigger> <Trigger Property=”ItemsControl.AlternationIndex” Value=”1″> <Setter Property=”Background” Value=”#EEE”></Setter> </Trigger> </Style.Triggers> </Style>

Disable DataGrid current cell border in FullRow selection mode

You could set the BorderThickness for DataGridCell to 0 <DataGrid … SelectionUnit=”FullRow”> <DataGrid.CellStyle> <Style TargetType=”DataGridCell”> <Setter Property=”BorderThickness” Value=”0″/> <!– Update from comments. Remove the focus indication for the selected cell –> <Setter Property=”FocusVisualStyle” Value=”{x:Null}”/> </Style> </DataGrid.CellStyle> <!– … –> </DataGrid>

DataGrid’s selected row color when inactive

After ages of searching, I found a surprisingly simple way to do this that’s cleaner than the Got/LostFocus approach posted earlier: <DataGrid.Resources> <SolidColorBrush x:Key=”{x:Static SystemColors.InactiveSelectionHighlightBrushKey}” Color=”DarkGray”/> </DataGrid.Resources> This just sets the inactive background colour to DarkGray, leaving the active background colour to the default, but you can change that too using the SystemColors.HighlightBrushKey too of … Read more

WPF StringFormat on Label Content

The reason this doesn’t work is that the Label.Content property is of type Object, and Binding.StringFormat is only used when binding to a property of type String. What is happening is: The Binding is boxing your MaxLevelOfInvestment value and storing it the Label.Content property as a boxed decimal value. The Label control has a template … Read more

Binding ItemsSource of a ComboBoxColumn in WPF DataGrid

Pls, check if DataGridComboBoxColumn xaml below would work for you: <DataGridComboBoxColumn SelectedValueBinding=”{Binding CompanyID}” DisplayMemberPath=”Name” SelectedValuePath=”ID”> <DataGridComboBoxColumn.ElementStyle> <Style TargetType=”{x:Type ComboBox}”> <Setter Property=”ItemsSource” Value=”{Binding Path=DataContext.CompanyItems, RelativeSource={RelativeSource AncestorType={x:Type Window}}}” /> </Style> </DataGridComboBoxColumn.ElementStyle> <DataGridComboBoxColumn.EditingElementStyle> <Style TargetType=”{x:Type ComboBox}”> <Setter Property=”ItemsSource” Value=”{Binding Path=DataContext.CompanyItems, RelativeSource={RelativeSource AncestorType={x:Type Window}}}” /> </Style> </DataGridComboBoxColumn.EditingElementStyle> </DataGridComboBoxColumn> Here you can find another solution for the problem you’re facing: … Read more

How to set DataGrid’s row Background, based on a property value using data bindings

Use a DataTrigger: <DataGrid ItemsSource=”{Binding YourItemsSource}”> <DataGrid.RowStyle> <Style TargetType=”DataGridRow”> <Style.Triggers> <DataTrigger Binding=”{Binding State}” Value=”State1″> <Setter Property=”Background” Value=”Red”></Setter> </DataTrigger> <DataTrigger Binding=”{Binding State}” Value=”State2″> <Setter Property=”Background” Value=”Green”></Setter> </DataTrigger> </Style.Triggers> </Style> </DataGrid.RowStyle> </DataGrid>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)