Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change Button Image When Enabled/Disabled
Message
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01470823
Message ID:
01470839
Views:
24
>>I put a button on a window and it's disabled. For the image I used a greyed out version of the image. When the button becomes enabled I'd like to swap the image to the enabled pic.
>>
>>Can someone point me in the right direction?
>>
>>Thanks
<Button x:Name="MyButton">
>            <StackPanel>
>                <TextBlock>Do Something</TextBlock>
>                <Image >
>                    <Image.Style>
>                        <Style>
>                            <Style.Triggers>
>                                <DataTrigger Binding="{Binding ElementName=MyButton,Path=IsEnabled}" Value="false">
>                                    <Setter Property="Image.Source" Value="disabledimage.png"/>
>                                </DataTrigger>
>                                <DataTrigger Binding="{Binding ElementName=MyButton,Path=IsEnabled}" Value="true">
>                                    <Setter Property="Image.Source" Value="enabledimage.png"/>
>                                </DataTrigger>
>                            </Style.Triggers>
>                        </Style>
>                    </Image.Style>
>                </Image>
>            </StackPanel>
></Button>
(assuming the image files are in the relevant location and have BuildAction = Resource....)


WOW. Awesome. Thanks!
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform