Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want button to behave w.r.t image as it is size of image.Actually i want to show button as it is of image provided. For example in below code my image source is changing but other code is same.
<Button  x:Name="BtnMin"  Content=""  Click="btnStartStop_Click" Margin="403.956,88.106,316.044,379.656" RenderTransformOrigin="0.5,0.5">
          
            <Button.Template>
                <ControlTemplate>
                    <Grid>
                        <Ellipse>
                            <Ellipse.Fill>
                                <ImageBrush ImageSource="Images/minimize.png"/>
                            </Ellipse.Fill>
                        </Ellipse>
                    </Grid>
                </ControlTemplate>
            </Button.Template>
        </Button>
 <Button  x:Name="btnStartStop"  Content="" Margin="84.851,0,495.149,258.284" VerticalAlignment="Bottom" Click="btnStartStop_Click">
            <Button.Template>
                <ControlTemplate>
                    <Grid>
                        <Ellipse>
                            <Ellipse.Fill>
                                <ImageBrush ImageSource="Images/glossyicon.png"/>
                            </Ellipse.Fill>
                        </Ellipse>
                    </Grid>
                </ControlTemplate>
            </Button.Template>
        </Button>

Can any one suggest how to create template where in code I will apply so my code size will reduce.
Posted

1 solution

Hello Vishal, I Understood your concern, for your specific issue you need to create style for that particular button and had to assign value at runtime of image source using converter


suited code for your concern.

http://wpfadv.blogspot.in/2010/03/image-button-control-template.html[^]


You might find this process bit lengthy for your two button but if you have same thing for number of buttons then you can go with provided link way to define a style for a button.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900