I need to pass in the controls name to a method in a security object that returns a boolean value for the IsEnabled property and another method that returns its Visibility(Collapsed, Hidden, or Visible). These both have to be checked for permission purposes.
I have tried using an ObjectDataProvider but all the examples show only user input from a textbox for the parameters. I specifically need to pass a control name to the method based off the button's x:Name property.
What is the simplest and most efficient way of handling this problem. Thanks in advance.
UPDATE: I am trying to use a converter and this is the convert method I came up with:
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (values != null)
{
DataTable tblPermissions = (DataTable)values[0];
string sFunctionName = values[1].ToString();
DataRow[] rows = tblPermissions.Select("fun_name = '" + sFunctionName + "'");
if ((bool)rows[0]["fun_enable"])
return true;
else
return false;
}
return string.Empty;
}
The following is the xaml:
<Button.IsEnabled>
<MultiBinding Converter="{StaticResource IsFunctionEnabledConverter}">
<Binding ElementName="{StaticResource PermissionsTable}" />
<Binding ElementName="btnSave" Path="Name" />
</MultiBinding>
</Button.IsEnabled>