Interaction logic for QuestionControl.xaml
Inheritance: System.Windows.Controls.UserControl
Exemplo n.º 1
0
        public UIElement Visit(ComputedQuestion question)
        {
            QuestionControl questionControl = new QuestionControl(question.Id);

            questionControl.AddQuestionLabel(question.Text);
            Control ioControl = question.Type.Accept <UIElement>(this) as Control;

            // create binding to control (writes value of questionControl to value of ioControl)
            Binding bind = new Binding("MyValue");

            bind.Source                = questionControl;
            bind.Converter             = question.Type.Accept <IValueConverter>(new ConverterVisitor()) as IValueConverter;
            bind.Mode                  = BindingMode.OneWay;
            bind.FallbackValue         = "";
            bind.UpdateSourceTrigger   = UpdateSourceTrigger.PropertyChanged;
            bind.NotifyOnTargetUpdated = true;
            ioControl.SetBinding(question.Type.Accept <DependencyProperty>(new DependencyPropertyVisitor()) as DependencyProperty, bind);
            questionControl.AddIOControl(ioControl, false);
            this._computedList.Add(new Tuple <QSExpression, UIElement>(question.Expression, questionControl));
            return(questionControl);
        }
Exemplo n.º 2
0
        public UIElement Visit(Question question)
        {
            QuestionControl questionControl = new QuestionControl(question.Id);

            questionControl.AddQuestionLabel(question.Text);
            Control ioControl = question.Type.Accept <UIElement>(this) as Control;

            // create binding to control (writes value of ioControl to value of questionControl)
            Binding bind = new Binding("MyValue");

            bind.Source                = questionControl;
            bind.Converter             = question.Type.Accept <IValueConverter>(new ConverterVisitor()) as IValueConverter;
            bind.Mode                  = BindingMode.OneWayToSource;
            bind.UpdateSourceTrigger   = UpdateSourceTrigger.PropertyChanged;
            bind.NotifyOnSourceUpdated = true;
            ioControl.SetBinding(question.Type.Accept <DependencyProperty>(new DependencyPropertyVisitor()) as DependencyProperty, bind);
            questionControl.SourceUpdated += new EventHandler <DataTransferEventArgs>(questionControl_SourceUpdated);
            questionControl.AddIOControl(ioControl, true);

            this._evaluator.SetValue(question.Id, question.Type.GetUndefined());
            questionControl.MyValueChanged += new DependencyPropertyChangedEventHandler(questionControl_ContentChanged);
            return(questionControl);
        }