Skip to content

IsVisible binding without a path is not applied #17587

Closed
@TomEdwardsEnscape

Description

@TomEdwardsEnscape

Describe the bug

A binding without a property path applied to IsVisible will not be evaluated. The control will remain visible when it should be hidden.

Adding a path of $self.DataContext works around the issue.

To Reproduce

Start Sandbox with this window XAML:

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
        x:Class="Sandbox.MainWindow" x:CompileBindings="False">
  <StackPanel>
    <Border IsVisible="{Binding, Converter={x:Static ObjectConverters.IsNotNull}}" Height="19" Background="Red" />
    <Border IsVisible="{Binding $self.DataContext, Converter={x:Static ObjectConverters.IsNotNull}}" Height="19" Background="Green" />
  </StackPanel>
</Window>

You will see this:

image

Expected behavior

The Border with the red background should not be visible.

Avalonia version

11.2.1

OS

Windows

Additional context

Not reproducible in 11.1.x

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions