WPF DependencyProperty Register Default Value
WPF > DependencyProperty> Register > Default ValuepublicstaticreadonlyDependencyPropertyUpdateSourceTriggerProperty = DependencyProperty.Register("UpdateSourceTrigger",...
View ArticleWPF Rectangle with Text
WPF > Rectangle > Add Text<Window x:Class="Rectangle.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"...
View ArticleTextBlock WPF Example
WPF > Controls > TextBlock A TextBlock can contain a string in its Text property.TextBlock is designed to be lightweight and is optimized for single-line display.Example<Window...
View ArticleGridSplitter WPF Example
WPF > Controls > GridSplitter <Window x:Class="GridSplitter.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"...
View ArticleBinding ComboBox to Enum and use Tag as SelectedValuePath
WPF > Controls > ItemsControl > ComboBox> Bind ComboBox to EnumXAML<Window x:Class="ComboBoxTag.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"...
View ArticleSlider WPF Example
WPF > Controls > Slider <Grid> <TextBox Text="{Binding ElementName=Slider, Path=Value, UpdateSourceTrigger=PropertyChanged}"...
View ArticleRound line WPF code behind
WPF > Line Line line = newLine{ Stroke = Brushes.Blue, StrokeThickness = 18, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round, Height= 50, X1 = 50, X2 = 100, Y1 = 10, Y2 =...
View ArticleGet rectangles from canvas WPF code behind
WPF > Controls > Layout > Canvas > ChildrenExample Get all rectangles from canvas.privateList<Rectangle> GetRectangles(){ return...
View ArticleGet Current Row WPF DataGrid
WPF > Controls > ItemsControl > DataGrid > ItemContainerGenerator > ContainerFromIndexReturns the element corresponding to the item at the given index.ExampleHow to get current row if...
View ArticleConvert Hex to SolidColorBrush
WPF > System.Windows.Media > BrushConverterBrushConverter is used to convert a Brush object to or from another object type.Example:row.Background =...
View ArticleClear Sort WPF DataGrid
WPF > Controls > ItemsControl > DataGrid > Clear Sort_collectionView = (CollectionView)CollectionViewSource.GetDefaultView(dataGrid.Items);_collectionView.SortDescriptions.Clear();
View ArticleSet DataGrid DataGridRow Background color WPF
WPF > DataGrid > DataGridRow > Background<DataGrid.RowStyle> <Style TargetType="DataGridRow"> <Style.Triggers> <DataTrigger Binding="{Binding IsValid}"...
View ArticleFind TextBox control ComboBox WPF
WPF > Controls > ItemsControl > ComboBoxUse FindName to find an element that has the provided identifier name.PART_EditableTextBoxTextBoxContains the text of the ComboBoxExamplevar textBox =...
View ArticleDisable row selection datagrid WPF
How to disable row selection in datagrid WPF?Answer:myDataGrid.IsHitTestVisible = false;
View ArticleFrameworkElementFactory focus on load element
WPF > FrameworkElementFactory > AddHandlerFrameworkElementFactory textBox = newFrameworkElementFactory(typeof(TextBox));textBox.AddHandler(TextBox.LoadedEvent,...
View ArticleScrollToTop DataGrid WPF
WPF> DataGrid > Scroll To Topvar border = VisualTreeHelper.GetChild(myDataGrid, 0) asDecorator;if (border != null&& border.Child !=null){ var scrollViewer = border.Child asScrollViewer;...
View ArticleBind Width to another Width control WPF
WPF > Binding > Width<Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="{Binding ElementName=controlName, Path=ActualWidth}"/> </Grid.ColumnDefinitions>
View ArticleGet Vertical ScrollBar Width WPF
WPF > Windows > SystemParameters> VerticalScrollBarWidthThis value indicates the width (in pixels) of a vertical scroll bar.SystemParameters.VerticalScrollBarWidth
View ArticleGridViewColumnHeader WPF Example
WPF > Controls > ContentControl > GridViewColumnHeaderGridViewColumnHeader object is a button control that is derived from ButtonBase. Column headers in a GridView view mode are...
View Article