將按鈕的命令綁定到動作後,我調用一個暴露進度事件的對象。聲明性進度條綁定
event System.EventHandler<ProgressChangedEventArgs> ProgressChanged
我想顯示在我的XAML中的最佳途徑。
一種方法可以在我的VM公開兩個綁定字段
member x.Iteration with get() = _iteration
and set(v:int) = _iteration <- v
x.NotifyPropertyChanged <@[email protected]>
member x.IterationVisible with get() = _iterationVisible
and set(v:bool) = _iterationVisible <- v
x.NotifyPropertyChanged <@[email protected]>
又在哪裏我叫要執行的操作,我只想更新屬性
member x.CompleteInference(algorithm:IGeneratedAlgorithm) =
x.IterationVisible <- true
algorithm.ProgressChanged.Add(fun args -> x.Iteration <- args.Iteration)
algorithm.run()
x.IterationVisible <- false
這導致了2個問題:
是否有直接的方式在F#暴露
progressChanged
事件,而不經過此中介Iteration
財產,可以由WPF處理?它是我們可以得到的最具說明性的/我們是否總是需要在某處存儲某個狀態?另外,有沒有一種自然的方式來做這個'狀態機'綁定完全在XAML?