简体   繁体   中英

Visibility binding on TextView not working

I am having problems binding Visibility to TextView . I have verified that the bound property returns a bool false. I also have a Checkbox whose Visibility is bound to the same property and that seems to work. See below:

<CheckBox
    android:id="@+id/checkBox1"
    local:MvxBind="Checked ConfirmLock; Visibility Visibility(ConfirmLockVisible)"
    style="@style/checkbox" />

<TextView
    android:text="Confirm Lock"
    android:textSize="18dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="4dp"
    localMvxBind="Visibility Visibility(ConfirmLockVisible)"
    style="@style/form_label.spacer" />

In the ViewModel :

private bool _confirmLockVisible;
public bool ConfirmLockVisible
{
    get { return _confirmLockVisible; }
    set
    {
        _confirmLockVisible = value;
        RaisePropertyChanged(() => ConfirmLockVisible);
    }
}

There is nothing special happening in the ViewModel , just that the property is being set based on data returned from a database query. And based on the behavior of the Checkbox , it appears that the property is set correctly.

You're missing a : in your TextView binding there:

localMvxBind="Visibility Visibility(ConfirmLockVisible)"

should be

local:MvxBind="Visibility Visibility(ConfirmLockVisible)"

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