Enabling Scrollbar in WPF

Put a ScrollViewer inside your Window: <Window x:Class=”WpfApplication2.Window1″ xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Title=”Window1″ Height=”300″ Width=”300″> <ScrollViewer > <!– Window content here –> </ScrollViewer> </Window>

How to automatically scroll ScrollViewer – only if the user did not change scroll position

You can use ScrollChangedEventArgs.ExtentHeightChange to know if a ScrollChanged is due to a change in the content or to a user action… When the content is unchanged, the ScrollBar position sets or unsets the auto-scroll mode. When the content has changed you can apply auto-scrolling. Code behind: private Boolean AutoScroll = true; private void ScrollViewer_ScrollChanged(Object … Read more

How to define TextBox input restrictions?

I’ve done this in the past with an attached behavior, which can be used like this: <TextBox b:Masking.Mask=”^\p{Lu}*$”/> The attached behavior code looks like this: /// <summary> /// Provides masking behavior for any <see cref=”TextBox”/>. /// </summary> public static class Masking { private static readonly DependencyPropertyKey _maskExpressionPropertyKey = DependencyProperty.RegisterAttachedReadOnly(“MaskExpression”, typeof(Regex), typeof(Masking), new FrameworkPropertyMetadata()); /// <summary> … Read more

Grid’s SharedSizeGroup and * sizing

DefinitionBase.SharedSizeGroup Property (Microsoft Docs): Columns and rows that participate in size-sharing do not respect Star sizing. In the size-sharing scenario, Star sizing is treated as Auto If you use star then all columns would be the same width, so you should assign the same SharedSizeGroup to all if you do not mind the auto-sizing aspect: … Read more

How to get WPF Window to autosize to content and no more

You need to use SizeToContent property, check the msdn link. Example: <Window xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″ xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″ … SizeToContent=”WidthAndHeight”>

How to stretch in width a WPF user control to its window?

You need to make sure your usercontrol hasn’t set it’s width in the usercontrol’s xaml file. Just delete the Width=”…” from it and you’re good to go! EDIT: This is the code I tested it with: SOUserAnswerTest.xaml: <UserControl x:Class=”WpfApplication1.SOAnswerTest” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Height=”300″> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Name=”LeftSideMenu” Width=”100″/> <ColumnDefinition Name=”Middle” Width=”*”/> <ColumnDefinition Name=”RightSideMenu” Width=”90″/> </Grid.ColumnDefinitions> <TextBlock … Read more

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