Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        public void BindMenuItems(List <Control> namedElements)
        {
            if (_isBindingSet)
            {
                return;
            }

            // Binds the control visible and enabled properties.
            WinFormExtensionMethods.BindToolStripItemProxyProperties(namedElements, _viewModel, _bindingManager);

            _isBindingSet = true;
        }
Exemplo n.º 3
0
        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;
        }