Пример #1
0
        /// <summary>
        /// Creates a editor control depending on the parameters controltype
        /// </summary>
        /// <param name="dataCommand">The data command.</param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        private UserControl CreateDataCommandControl(DataCommand dataCommand)
        {
            if (string.IsNullOrEmpty(dataCommand.CustomControlName))
            {
                throw new Exception(string.Format("No control for the datacommand '{0}' is found", dataCommand.Name));
            }

            var commandControl = ViewManager.Instance.CreateUserControl(dataCommand.CustomControlName);

            commandControl.Name = dataCommand.GetType().Name;

            return(commandControl);
        }
Пример #2
0
        private void SwitchControls(DataCommand dataCommand)
        {
            this.ClearAndHideControls();

            if (dataCommand == null)
            {
                return;
            }

            string controlName    = dataCommand.GetType().Name;
            var    commandControl = this.GetExistingDataCommandControl(controlName);

            if (commandControl == null)
            {
                commandControl = this.CreateDataCommandControl(dataCommand);
                this.LayoutRoot.Children.Add(commandControl);
            }

            commandControl.Visibility = Visibility.Visible;

            ((DataCommandEditor)commandControl).CurrentDataCommand = dataCommand;

            this.currentCommandControl = (DataCommandEditor)commandControl;
        }