views:

18

answers:

2

hello,

the title says it all, instead of disabling the button which happens automatically, i would like to hide (or rather collapse the visibility of) the button.

thanks for your help konstantin

+1  A: 

Use the BooleanToVisibilityConverter and bind to a bool as described here.

klausbyskov
this is a possibility, thanks. can this be done without adding an extra property? trying to reduce the amount of code.
akonsu
+3  A: 

You could use a Style and Triggers, assuming that the command is in charge of setting the Button enabled/disabled:

        <Button x:Name="btnMoveUp"
                Command="{x:Static local:Window1.MoveItemUp}">
            <Button.Style>
                <Style TargetType="{x:Type Button}" >
                    <Style.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>

Note that you can define this Style at a higher scope and share it - I just put it right with the Button for a more compressed example.

Wonko the Sane