I need to pass the name of the control to a method in a security object that returns a boolean for the IsEnabled property and another method that returns its visibility (minimized, hidden, or visible). Both of these should be checked for permission purposes.
I tried using ObjectDataProvider, but all the examples show only user input from the text field for the parameters. I need to pass a control name to a method based on the name of the x: Name button.
What is the easiest and most effective way to solve this problem. Thanks in advance.
UPDATE:
I am trying to use a converter, and this is the conversion method I came across:
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 xaml:
<Button.IsEnabled>
<MultiBinding Converter="{StaticResource IsFunctionEnabledConverter}">
<Binding ElementName="{StaticResource PermissionsTable}" />
<Binding ElementName="btnSave" Path="Name" />
</MultiBinding>
</Button.IsEnabled>