WPF > Controls > ItemsControl > DataGrid > Clear Sort
_collectionView = (CollectionView)CollectionViewSource.GetDefaultView(dataGrid.Items);
_collectionView.SortDescriptions.Clear();
Search This Blog
Wednesday, November 16, 2016
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);
Wednesday, October 19, 2016
Thursday, October 13, 2016
Round line WPF code behind
WPF > Line
Line line = new Line
{
Stroke = Brushes.Blue,
Stroke = Brushes.Blue,
StrokeThickness = 18,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
Height= 50,
X1 = 50,
X2 = 100,
Y1 = 10,
Y2 = 10
};
canvas.Children.Add(line);
Labels:
Lune
Thursday, September 29, 2016
Slider WPF Example
WPF > Controls > Slider
<Grid>
<TextBox
Text="{Binding ElementName=Slider, Path=Value, UpdateSourceTrigger=PropertyChanged}"
Margin="33,112,288,172"/>
<Slider
Maximum="100"
Name="Slider"
Margin="33,48,288,213"
IsSnapToTickEnabled="True"
TickFrequency="1" />
</Grid>
Monday, August 22, 2016
Binding ComboBox to Enum and use Tag as SelectedValuePath
WPF > Controls > ItemsControl > ComboBox > Bind ComboBox to Enum
XAML
XAML
<Window x:Class="ComboBoxTag.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ComboBox
SelectedValue="{Binding Rate, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
SelectedValuePath="Tag" Margin="0,0,306,295">
<!--
Tag is values of Rate enum -->
<ComboBoxItem Tag="Bad">Bad</ComboBoxItem>
<ComboBoxItem Tag="Low">Low</ComboBoxItem>
</ComboBox>
</Grid>
</Window>
C#
namespace ComboBoxTag
{
public enum Rate
{
Bad = 0,
Good = 1
}
}
Labels:
Controls
Subscribe to:
Posts (Atom)