In simple words, how to add a control template to my WPF Application? I am using Visual studio 2010 with .net 4.
Below are a few questions.
1) According to my understanding, a custom template is something that is used for re-defining an already defined default settings of a control. Am I right In this case ?
2) If we want the button to be with an image whenever I drag and drop from tool-box, then I should have over-ridden the XAML code for the button somewhere.
For example, I have got a control template code below that re-defines how the progress bar should be
[1. A simple example from stack overflow] WPF progressbar style
<ControlTemplate x:Key="CustomProgressBar" TargetType="ProgressBar" >
<Grid Name="TemplateRoot" SnapsToDevicePixels="True">
<Rectangle RadiusX="2" RadiusY="2" Fill="Transparent" />
<Border CornerRadius="0,0,0,0" Margin="1,1,1,1">
<Border.Background>
<SolidColorBrush Color="Transparent"/>
</Border.Background>
</Border>
<Border BorderThickness="0,0,0,0" BorderBrush="Transparent" Margin="1,1,1,1">
<Border.Background>
<SolidColorBrush Color="Transparent"/>
</Border.Background>
</Border>
<Rectangle Name="PART_Track" Margin="1,1,1,1" />
<Decorator Name="PART_Indicator" Margin="1,1,1,1" HorizontalAlignment="Left">
<Grid Name="Foreground">
<Rectangle Fill="Transparent" Name="Indicator" />
<Grid Name="Animation" ClipToBounds="True">
<Border Name="PART_GlowRect" Width="100" Margin="0,0,0,0" HorizontalAlignment="Left" Background="LightBlue"/>
</Grid>
<Grid Name="Overlay">
</Grid>
</Grid>
</Decorator>
<Border BorderThickness="0" CornerRadius="0,0,0,0" BorderBrush="Transparent" />
</Grid>
</ControlTemplate>
Also , I tried creating a custom control. Projects->New->Custom control and the VS-2010 produces two files Customcontrol.cs and customcontroldesigner.cs. What should I do afterwards ? (Say I need a button with an image hence always).
Thanks.