2013-08-26 121 views
0

我想綁定MVVMCross對話框的Visible屬性。使用MVVMCross和Monotouch,你可以綁定到Dialog.Section Visible屬性嗎?

var refillSection = new Section() { 
    new StringElement("Refill").Bind(this, "SelectedCommand OpenExternal") 
}.Bind(this, "Visible IsExternal,Converter=Visibility"); 
root.Add(refillSection); 

我也曾嘗試綁定直接可見的元素,但也不管用。

var refillSection = new Section() { 
    new StringElement("Refill").Bind(this, "SelectedCommand OpenExternal;Visible IsExternal,Converter=Visibility") 
}; 
root.Add(refillSection); 

我做錯了什麼?我安裝了可見性插件。

回答

2

Visible在對話框Element實際上是個bool是 - 看https://github.com/slodge/MvvmCross/blob/v3/CrossUI/CrossUI.Touch/Dialog/Elements/Element.cs#L71

正因爲如此,結合Visible當你不需要使用任何Visibility轉換器。

Visible本身最近加入對話在這拉請求 - https://github.com/slodge/MvvmCross/pull/294

正如你可能能夠從該請求的討論中看到,有一個關於如何擴展Visible使其工作了一些討論,有Section s,甚至對於Root。然而,可悲的是,我不認爲這些討論成功實施 - 所以我不相信默認Section目前適用於Visible

爲顯示/隱藏您的Section S的一個,您的具體易於理解的情況,然後我想你可能能夠在您的應用程序來實現這個通過繼承和Section壓倒一切的一些功能可能還有DialogViewController/DialogAdapter類。如果有幫助,Section繼承的一個例子是BindableSectionhttps://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/BindableElements/BindableSection.cs

+0

我實際上使用了一個StyledStringElement的子類,它似乎不使用Visible。我添加了一個問題:https://github.com/slodge/MvvmCross/issues/403。我會看看隱藏部分。 –

相關問題