Q:

Binding the checked state of a togglebutton to the visibility of a usercontrol

I have a way of doing this now using code-behind and changing visibility of 'panels' , but I wonder if this can be done in a straight xaml way?

A:

You should be able to bind this using ElementName, along with an IValueConverter that converts true/false to Visibility:
<Grid>
    <Grid.Resources>
        <local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
    </Grid.Resources>
    <UserControl Visibility="{Binding ElementName=toggle,
                                      Path=IsChecked,
                                      Converter={StaticResource BoolToVisibilityConverter}}" 
    />
    <ToggleButton x:Name="toggle" />
</Grid>

And the converter:
public class BoolToVisibilityConverter: IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var isChecked = (bool)value;
        return isChecked ? Visibility.Visible : Visibility.Collapsed;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

