I had a similar problem tonight :-)
I think the best way to do this stuff is to bind visibility to a property in the ViewModel.
You can use a converter for each of these variables (so you can return Visibility.Collapsed or Visibility.Visible when expected ;-)).
You can use the “CanExecute” method for each of these buttons so that button 2 cannot be executed before button 1 is pressed (for example, using a boolean variable). You can use the commands to do this, so that the code associated with each button is in the ModelView.
If you need examples, I can insert them from my work on Monday :-).
A small example, directly coding it here (I don't have Silverlight installed here).
Your opinion should look like this:
<Button Content="Activate Work Order" Command="{Binding ActivateWorkOrderCommand}" />
You can find examples of using commands in MVVM, here you have a simple example .
For converters, if you still prefer to hide and show buttons, you must declare a new class that implements IValueConverter:
public class UniversalConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if(_SelectedWorkOrder.DateActivated.ToShortDateString() != "1/1/0001") { return Visibility.Collapsed; } else { return Visibility.Visible; }
Thus, your view should also bind the converter:
<Button Content="Activate Work Order" Visibility="{Binding DateActivated, Converter={StaticResource DateConverter}}" />
Hope this helps you; -)