Archive for the ‘WPF’ Category

Automatically size the app Window to accommodate the content

January 24, 2011

SizeToContent=”Height/Width/WidthAndHeight”

How to bind a cutom property to user control in WPF

June 29, 2010

<UserControl x:Class="RMSControlLib.Resources.BevelBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
x:Name="RootControl"
d:DesignWidth="30" d:DesignHeight="30">
...
<Border x:Name="Box"
...
Background="{Binding ElementName=RootControl, Path=FillBrush}"/>
...
</UserControl>

How to inherit from a typed style in WPF?

June 28, 2010

<Style x:Key="ThumbViewCloseBtnStyle"
TargetType="{x:Type Button}"
BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="MinHeight" Value="0"/>
...
</Style>

Create a Brush object in WPF

February 15, 2010

SolidColorBrush brush =  new SolidColorBrush(Colors.Green));

or even simpler:

SolidColorBrush brush = Brushes.Green;