Reputation: 16239
How do i display or show image to button using code behind in silverlight depending upon condition?
i'm new bie.
there are some conditions depending upon that i need to show image on button please help.`
<Button x:Name="myButton" Width="24" Height="24">
<Image Source="myImage.png" Stretch="None"/>
</Button>
How can i change image source depending upon condition in code behind?
Upvotes: 0
Views: 549
Reputation: 2380
<Button x:Name="myButton" Width="24" Height="24">
<Image x:Name="myImage" Source="myImage.png" Stretch="None"/>
</Button>
Then do:
if (someCondition)
{
myImage.Visibility = Visibility.Visible;
}
else
{
myImage.Visibility = Visibility.Collapsed;
}
Does that work for you?
Upvotes: 1