Example of Graphics in WPF
The main objective of this article is to make you understand how to work on Graphics in WPF. This is a very simple example on how to work on the appearance of an application. We have two views in WPF. Xaml view and code view. We will deal with Xaml view only because this article is dealing with appearance.
The main objective of this article is to make you understand how to work on Graphics in WPF.
Open a new WPF application from the Visual Studio.
In the XAML View, create a button.
All the below code is between
< Button Height="23" Margin="30,76,0,0" Name="Button1"
VerticalAlignment="Top" HorizontalAlignment="Left" Width="74">
< Button.Background>
< /Button.Background>Set Name
< /Button>
Create another button with a different background color.
< Button Height="23" Margin="0,0,30,76" Name="Button2"
VerticalAlignment="Top" HorizontalAlignment="Right" Width="74">
< Button.Background>
< /Button.Background>Set Name
< /Button>
Add a textbox to it in XAML and flip the text box
< TextBox RenderTransformOrigin=".5,.5" Height="21" Margin="30,29,81,0"
Name="textBox1" VerticalAlignment="Top">
< TextBox.RenderTransform>
< /TextBox.RenderTransform>
< /TextBox>
Add a label and do a skew transform
< Label Margin="30,124,81,115" Name="label1">
< Label.RenderTransform>
< SkewTransform AngleX="30" AngleY="20">
< /Label.RenderTransform>
< /Label>
Before
< Window.Background>
< LinearGradientBrush>
< GradientStop Color="Red" Offset="0"/>
< GradientStop Color="Yellow" Offset=".5"/>
< GradientStop Color="Lime" Offset="1"/>
< /LinearGradientBrush>
< /Window.Background>
LinearGradientBrush is used to create an appearance that blend two or more colors along a gradient which allows a variety of effects.
Now run the application.
You could see a different appearance than the normal.