Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Change Button Image When Enabled/Disabled
Message
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01470823
Message ID:
01470839
Vues:
25
>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform