C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » WPF »

Adding style or template to my buttom.


Posted Date: 04 Nov 2009      Posted By: Ramesh N D      Member Level: Gold     Points: 1   Responses: 1



Hi All

The below is my XAML code in WPF. now i want add style or template to my buttom.

XAML :

<Window x:Class="Sample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="434" Width="716">
<Grid Name="MasterGrid">
<Button>Click Me</Button>
</Grid>
</Window>


Where to Add This Template ?

<Style x:Key="DialogButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Ellipse Fill="{TemplateBinding Background}"
Stroke="{TemplateBinding BorderBrush}"/>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>


Where to Add?



<Button Style="{StaticResource DialogButtonStyle}" />


Thanks
Ramesh.N.D







Responses

Author: K Hari Prasad    04 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

You can add the button style in window.resources.

after

Title="Window1" Height="434" Width="716">

like below


<Window.resources>

<Style x:Key="DialogButtonStyle" TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Ellipse Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}"/> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> </Grid> </ControlTemplate> </Setter.Value> </Setter></Style>

</window.resources>



Post Reply
You must Sign In to post a response.
Next : Wpf
Previous : How to create MouseDown event in WPF
Return to Discussion Forum
Post New Message
Category: WPF

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use