0

I developed an app on windows phone using c# and xaml.

I want to change my own project to mvvm style. when i do the structure building, i face a question:

one business logic in my app is when the user changes the category via the listbox, i will change the colour of the controls in current page.

This is easy when using the code-behind, I just write a helper method which I can run when the user triggers the finish event.

if (category==1){
  grid.color = red;
  button.color = red;
  listbox.color = red;}
else if (category==2){
  grid.color = blue;
  button.color = blue;
  listbox.color = blue;}

But how to implement this in mvvm style? In mvvm, how can I change a bunch of binding at one time?

4

1 回答 1

0

首先,您将视图模型中的属性绑定到列表框的选定项。

然后,您将控件的 Color 属性绑定到视图模型中的某个属性。您还需要指定一个 ValueConverter 以将 Item 转换为 Color。

于 2013-05-02T00:48:19.820 回答