Best Way To Design This
-
I want to create menu in my app that looks like Zune[^] So I styled a button, and it looks fine. The question is, what's the best way to load this? Would you define each button on its own in XAML or use some kind of list or stackpanel that's bound to the VM? I would like the menu(s) to be dynamic, so I will have to bind the Caption, the Visibility, and the Command would be bound to something like Button1Command, Button2Command, ect. Then in the code behind determine what to do based of the state of the app. Also, when a button is clicked, it's FontWeight needs to be set to bold, and all other buttons to Normal. How would you do this? Sugggestions? Thanks
If it's not broken, fix it until it is
-
I want to create menu in my app that looks like Zune[^] So I styled a button, and it looks fine. The question is, what's the best way to load this? Would you define each button on its own in XAML or use some kind of list or stackpanel that's bound to the VM? I would like the menu(s) to be dynamic, so I will have to bind the Caption, the Visibility, and the Command would be bound to something like Button1Command, Button2Command, ect. Then in the code behind determine what to do based of the state of the app. Also, when a button is clicked, it's FontWeight needs to be set to bold, and all other buttons to Normal. How would you do this? Sugggestions? Thanks
If it's not broken, fix it until it is
You create a single style in a central location. This is called the resource dictionary. You then use this style in any buttons defined in any xaml. It is not advisable to have this style copy pasted in every single xaml. That would be a maintenance nightmare. The Visual State Manager class[^] should help you setup a transition for the fontweight task. You can also set up a simple animation for this task.
Build your own survey - http://www.factile.net
-
I want to create menu in my app that looks like Zune[^] So I styled a button, and it looks fine. The question is, what's the best way to load this? Would you define each button on its own in XAML or use some kind of list or stackpanel that's bound to the VM? I would like the menu(s) to be dynamic, so I will have to bind the Caption, the Visibility, and the Command would be bound to something like Button1Command, Button2Command, ect. Then in the code behind determine what to do based of the state of the app. Also, when a button is clicked, it's FontWeight needs to be set to bold, and all other buttons to Normal. How would you do this? Sugggestions? Thanks
If it's not broken, fix it until it is
You create a single style in a central location. This is called the resource dictionary. You then use this style in any buttons defined in any xaml. It is not advisable to have this style copy pasted in every single xaml. That would be a maintenance nightmare. The Visual State Manager class[^] should help you setup a transition for the fontweight task. You can also set up a simple animation for this task.
Build your own survey - http://www.factile.net
-
I want to create menu in my app that looks like Zune[^] So I styled a button, and it looks fine. The question is, what's the best way to load this? Would you define each button on its own in XAML or use some kind of list or stackpanel that's bound to the VM? I would like the menu(s) to be dynamic, so I will have to bind the Caption, the Visibility, and the Command would be bound to something like Button1Command, Button2Command, ect. Then in the code behind determine what to do based of the state of the app. Also, when a button is clicked, it's FontWeight needs to be set to bold, and all other buttons to Normal. How would you do this? Sugggestions? Thanks
If it's not broken, fix it until it is
I am not aware of Zune, however, I think you can use a Menu control and set its source to a collection ObservableCollection MenuItems. interface IMenuItem { string Caption; Visibility MenuVisibility; ICommand Command;} Bind the above properties in the MenuItem's ItemTemplate or HiearchicalTemplate. Apply DataTrigger on the MenuVisibility property to set visibility. Also you can customize the default menuitem's template style and modify the template as per your requirement. Please refer the below link which will give an idea on how to use the menu item template. http://msdn.microsoft.com/en-us/library/ms752296%28v=vs.85%29[^] http://msdn.microsoft.com/en-us/library/ms747082%28v=vs.85%29.aspx[^]