我需要編寫一個小應用程序來讀取配置文件並使用它生成一些報告。我希望最終能夠使用MVVM,但開始起來相當棘手。哦,我正在使用Caliburn.Micro框架。在MVVM WPF應用程序的視圖模型之間傳遞應用程序狀態
因此,這是我,其上具有與3個按鈕的帶狀的殼(承載其他視圖主視圖):
1)打開文件 2)顯示設定 3)上顯示結果
和其他兩個視圖,SettingsView和ResultsView帶有按鈕來生成和刪除報告。
所以我猜這個視圖結構會是這樣:
ShellView
Ribbon
OpenFileButton
SettingsButton
ResultsButton
ContentControl (hosts SettingsView and ResultsView)
SettingsView
CalculateResultsButton
ResultsView
CancelResultsButton
棘手的部分是這樣的:
1. "Show settings" button is disabled until a file is opened (via Open file).
2. "Show results" button is disabled until a report is calculated (via a
method in SettingsViewModel).
3. If a report is calculated, the CalculateResultsButton is disabled and
CancelResultsButton is enabled and vice versa.
請告訴我怎麼能做到這一點?我不知道我應該採取什麼策略。我的非MVVM思維大腦說,我應該創建一個狀態變量,然後以某種方式將這些按鈕綁定到該變量,但我想這不會在MVVM世界中工作,對吧?任何代碼示例都會非常非常感謝!
非常感謝!
不理想。 Caliburn Micro避免了所有的ICommand和Guff。 http://caliburnmicro.codeplex.com/discussions/250844 – 2012-04-05 01:01:36