private static void BindComponentProperties(ToolStripItemProxy control, object viewModel, BindingManager bindingManager) { var property = viewModel.GetPropertyCaseInsensitive(control.Name + "Visible"); if (property != null) { // must enforce the Visible property control.Item.Visible = (bool)property.GetValue(viewModel, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance, null, null, null); WinFormExtensionMethods.DoBind(control, "Visible", viewModel, property.Name, bindingManager); } else { property = viewModel.GetPropertyCaseInsensitive(control.Name + "Enabled"); if (property != null) { // no need for enforce the Enabled property /*control.Item.Enabled = * (bool) property.GetValue(viewModel, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance, null, null, null);*/ WinFormExtensionMethods.DoBind(control, "Enabled", viewModel, property.Name, bindingManager); } } }
public void BindMenuItems(List <Control> namedElements) { if (_isBindingSet) { return; } // Binds the control visible and enabled properties. WinFormExtensionMethods.BindToolStripItemProxyProperties(namedElements, _viewModel, _bindingManager); _isBindingSet = true; }
private void MainForm_Load(object sender, EventArgs e) { if (_isBindingSet || _namedElements == null) { return; } // Binds the control visible and enabled properties. WinFormExtensionMethods.BindComponentProxyProperties(_namedElements, _viewModel, _bindingManager); _isBindingSet = true; }