ContentControl and Button Content Binding

Viewed 11

I am new to XAML.

I have a Mainview with a Button.

This button must display a UserControl by binding the content, and in the same time, the button must disappear.

My first try :

<ContentControl Content="{Binding CurrentViewModel}"/>
    <ContentControl>
        <Button Command="{Binding TestCommand}">
            <Grid >
                <Image Source="....."  />
                <TextBlock Text="Text on the button"/>
            </Grid>
        </Button>
    </ContentControl>

In this example, when I click on the button, my usercontrol is displayed but the button remains in the MainWindow which is normal.

Of course I can create a usercontrol with just the button and keep only <ContentControl Content="{Binding CurrentViewModel}"/> it will do the job, but is it possible to do it in XAML?

Something like "Display the button only if MainWindowViewModel is binded?"

Thanks.

0 Answers
Related