Monday, February 21, 2011

How to compare values of two controls with a trigger?

I have to buttons, named btnOK and btnSave.

I want that the IsEnabled of btnSave should be the same as the btnOK's value, i.e. if btnOK goes disabled, btnSave should do the same.

I actually need something like (pseudu):

<Button TabIndex="3" Name="btnOK">
    <Button.Triggers>
        <Trigger Property="IsEnabled">
            <Setter TargetName="btnSave" Property="IsEnabled" Value="Self.IsEnabled"/>
        </Trigger>
    </Button.Triggers>
</Button>
<Button Name="btnSave"/>
From stackoverflow
  • <Button Name="btnOK">OK</Button>
    <Button Name="btnSave" IsEnabled="{Binding IsEnabled, ElementName=btnOK}">Save</Button>
    

    HTH, Kent

    Shimmy : If I wouldn't have this question I could of died without knowing that the ElementName thing even exists.... Thanks man!!!

0 comments:

Post a Comment