I have a delegate that is called from native code to tell Visibility and IsEnabled for each button. Making 22 properties like
bool Insert_BtnSaveIsEnabled {get; set; }
Visibility Insert_BtnSaveVisibility {get; set; }
bool Insert_BtnSelectObjectsIsEnabled {get; set; }
Visibility Insert_BtnSelectObjectsVisibility {get; set; }
to ViewModel and bind a pair for each button's IsEnabled and Visbility in XAML does not sound reasonable. How this should be done?
ViewModel:
private int ControlsStateChange(string control, CommonDllInterface.FieldStateSet state)
{
//here I could have huge if-else clause
//to determine one of 22 properties to set
//and the value to assign to it
}
enum:
public enum FieldStateSet
{
Undefined = 0,
Inactive = 1,
Active = 2,
Visible = 3,
Hidden = 4
}
value Hidden is always mapped to Visibilty.Collapsed.
Here is part of the XAML (it is quite complex/long so these few buttons should do as an example):
<Button Name="Insert_BtnSave" Command="{ui:CommandHandler CommonCommandshandler}">
<Image Source="{Binding Converter={StaticResource nameToBitmapSource}}" DataContext="BmpSaveSettings" />
</Button>
<Button Name="Insert_BtnSelectObjects" Command="{ui:CommandHandler CommonCommandshandler}">
<Image Source="{Binding Converter={StaticResource nameToBitmapSource}}" DataContext="BmpBrwse" />
</Button>
<Button Name="Insert_BtnSelectPL" Command="{ui:CommandHandler CommonCommandshandler}" Visibility="{Binding Visibility}">
<Image Source="{Binding Converter={StaticResource nameToBitmapSource}}" DataContext="BmpPlanProperties" />
</Button>
<Button Name="Insert_BtnCopy" Command="{ui:CommandHandler CommonCommandshandler}" IsEnabled="{Binding IsEna}">
<Image Source="{Binding Converter={StaticResource nameToBitmapSource}}" DataContext="BmpCopy" />
</Button>
<Button Name="Insert_BtnDelete" Command="{ui:CommandHandler CommonCommandshandler}">
<Image Source="{Binding Converter={StaticResource nameToBitmapSource}}" DataContext="BmpDelete" />
</Button>
<Button Name="Insert_BtnEditProps" Command="{ui:CommandHandler CommonCommandshandler}">
<Image Source="{Binding Converter={StaticResource nameToBitmapSource}}" DataContext="BmpOfflineProperties" />
</Button>
Names of the buttons in XAML correspond to control-parameter value in delegate.