I am trying to bind the Visible property of a MVVMCross Dialog Section.
var refillSection = new Section() {
new StringElement("Refill").Bind(this, "SelectedCommand OpenExternal")
}.Bind(this, "Visible IsExternal,Converter=Visibility");
root.Add(refillSection);
I have also tried binding the Visible of the Element directly, but does not work either.
var refillSection = new Section() {
new StringElement("Refill").Bind(this, "SelectedCommand OpenExternal;Visible IsExternal,Converter=Visibility")
};
root.Add(refillSection);
Am I doing something wrong? I have the Visibility plugin installed.
Visible
on the DialogElement
s is actually abool
- see https://github.com/slodge/MvvmCross/blob/v3/CrossUI/CrossUI.Touch/Dialog/Elements/Element.cs#L71Because of this, you don't need to use any
Visibility
converters when binding toVisible
.Visible
itself was recently added to Dialog in this pull request - https://github.com/slodge/MvvmCross/pull/294As you may be able to see from the discussions on that request, there was some discussion there about how to extend
Visible
so that it worked forSection
s and even forRoot
. However, sadly I don't think those discussions reached a successful implementation - so I don't believe that the defaultSection
currently works forVisible
.For your specific well-understood scenario for showing/hiding one of your
Section
s, then I think you might be able to implement this in your app by inheriting and overriding some functionality inSection
and possibly also theDialogViewController
/DialogAdapter
classes. If it helps, one example ofSection
inheritance is theBindableSection
in https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/BindableElements/BindableSection.cs