Search This Blog
Tuesday, February 21, 2017
Disable row selection datagrid WPF
How to disable row selection in datagrid WPF?
Answer:
myDataGrid.IsHitTestVisible = false;
Labels:
DataGrid
Thursday, January 26, 2017
Find TextBox control ComboBox WPF
WPF > Controls > ItemsControl > ComboBox
Use FindName to find an element that has the provided identifier name.
Example
var textBox = comboBox.Template.FindName("PART_EditableTextBox", comboBox) as TextBox;
Use FindName to find an element that has the provided identifier name.
PART_EditableTextBox
|
TextBox
|
Contains the text of the ComboBox
|
Example
var textBox = comboBox.Template.FindName("PART_EditableTextBox", comboBox) as TextBox;
Labels:
ComboBox
Wednesday, December 14, 2016
Set DataGrid DataGridRow Background color WPF
WPF > DataGrid > DataGridRow > Background
<DataGrid.RowStyle>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<DataTrigger Binding="{Binding IsValid}" Value="true">
<Setter Property="Background" Value="Green"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding IsValid}" Value="false">
<Setter Property="Background" Value="Red"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
Labels:
WPF
Wednesday, November 16, 2016
Clear Sort WPF DataGrid
WPF > Controls > ItemsControl > DataGrid > Clear Sort
_collectionView = (CollectionView)CollectionViewSource.GetDefaultView(dataGrid.Items);
_collectionView.SortDescriptions.Clear();
_collectionView = (CollectionView)CollectionViewSource.GetDefaultView(dataGrid.Items);
_collectionView.SortDescriptions.Clear();
Labels:
DataGrid
Thursday, November 3, 2016
Convert Hex to SolidColorBrush
WPF > System.Windows.Media > BrushConverter
BrushConverter is used to convert a Brush object to or from another object type.
Example:
BrushConverter is used to convert a Brush object to or from another object type.
Example:
row.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFA7CDF0"));
Labels:
BrushConverter
Monday, October 24, 2016
Get Current Row WPF DataGrid
WPF > Controls > ItemsControl > DataGrid > ItemContainerGenerator > ContainerFromIndex
Returns the element corresponding to the item at the given index.
Example
How to get current row if row is not selected.
Returns the element corresponding to the item at the given index.
Example
How to get current row if row is not selected.
var index = dataGrid.Items.IndexOf(dataGrid.CurrentItem);
var row = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(index);
Subscribe to:
Posts (Atom)