简体   繁体   中英

Why is my Visibility binding not working?

I have a problem with one of my Visibility Bindings. In my application I have a Textbox and a combobox at nearly the same place. They are overlapping so I have two Variables in the background for their Visibility. They are in a Datagrid, so the Visibility Source will be provided from the list.

The Binding of my Combobox works absolutely fine, but the one of my Textbox doesn't

Here is my Code:

<TextBox    x:Name="Textvalue" 
            HorizontalAlignment="Left" 
            VerticalAlignment="Center" 
            Width="150" 
            BorderBrush="#FF383F55" 
            BorderThickness="0" 
            Foreground="White" 
            Background="#FF232734"
            Text="{Binding Path=Value, UpdateSourceTrigger=PropertyChanged}"
            Visibility="{Binding Path=IsPath}"/>

<ComboBox   x:Name="Combobox" 
            VerticalAlignment="Center" 
            Foreground="White" 
            Margin="3,3,3,3" 
            Height="23"
            ItemsSource="{Binding Path=ValueArray}" 
            SelectedValue="{Binding Path=Value, UpdateSourceTrigger=PropertyChanged}" 
            Style="{DynamicResource ComboBoxStyle1}" 
            Visibility="{Binding Path=IsCombobox}"/>

These are my Get Property for both (Both only have the Get Proberty):

public System.Windows.Visibility isPath
{
    get
    {
        return _IsPath;
    }
}

public System.Windows.Visibility IsCombobox
{
    get
    {
        return _IsCombobox;
    }
}

I hope you can help me because I don't know what's wrong here :/ Thanks in advance

What I have tried:

Tried to change the binding to a different Variable.

The property name in your code has a lower case 'i' public System.Windows.Visibility isPath and the XAML has an upper case I in binding IsPath. Change this and it should be working!

{Credit CS, I'd already started writing this}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM