/// <inheritdoc />
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value is AbstractUIViewModelBase)
            {
                return(value);
            }

            return(value switch
            {
                AbstractTextBox textBox => new AbstractTextBoxViewModel(textBox),
                AbstractDataList dataList => new AbstractDataListViewModel(dataList),
                AbstractButton button => new AbstractButtonViewModel(button),
                AbstractBoolean boolean => new AbstractBooleanViewModel(boolean),
                AbstractRichTextBlock richText => new AbstractRichTextBlockViewModel(richText),
                AbstractMultiChoice multiChoiceUIElement => new AbstractMultiChoiceViewModel(multiChoiceUIElement),
                AbstractForm form => new AbstractFormViewModel(form),
                AbstractUICollection elementGroup => new AbstractUICollectionViewModel(elementGroup),
                AbstractProgressIndicator progress => new AbstractProgressIndicatorViewModel(progress),
                AbstractColorPicker color => new AbstractColorPickerViewModel(color),

                _ => throw new NotSupportedException($"No match ViewModel was found for {value.GetType()}."),
            });
Esempio n. 2
0
 public static TElement GetElement <TElement>(this AbstractUICollection collection, string id) where TElement : AbstractUIElement
 {
     return(collection.OfType <TElement>().FirstOrDefault(x => x.Id == id));
 }