<Button x:Name="btnProfilePicture" HorizontalAlignment="Center" Click="btnProfilePicture_Click">
<Button.Template>
<ControlTemplate>
<Ellipse x:Name="ellipsePicture" Fill="Turquoise" Width="150" Height="150" Stroke="White" StrokeThickness="10">
</Ellipse>
</ControlTemplate>
</Button.Template>
</Button >
I have a button in ellipse shape, with color fill by default. I want to change the fill to an image in code-behind in runtime.
How can I do this?
More info: I tried to set the ellipse fill by using the "ellipsePicture" name but this name cannot be referenced in the code behind but I dont know the reason.
Try this:
Try it. After this modify you can set image to content. This changes you can made at XAML and runtime.
You can use Background property of the button to set image on the background.You can use it from code behind also like:
in your button click event add the following line
btnProfilePicture.Background=LoadBackgroundImage(yourfilename.jpg); //you can use .jpg,.jpeg,*.png
Try the following code..
On your code behind add the following line..
Vote me if this works!