Click here to Skip to main content
15,885,435 members
Articles / Desktop Programming / WPF

WPF Form Designer Prototype (MVVM)

Rate me:
Please Sign up or sign in to vote.
4.83/5 (31 votes)
3 Apr 2013CPOL9 min read 79.3K   3.4K   108  
Form designer with editable display properties and bindings. Generates XAML forms.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using XMLStudio_IDE.WPFControlUtils;
using XMLStudio_IDE.WPFControlUtils.WPFPropertyGridProxies;

namespace XMLStudio_IDE.Converters
{
    public class WPFPropertyGridProxyConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is TextBox)
                return new TextBoxProxy(value as TextBox);
            
            if (value is Label)
                return new LabelProxy(value as Label);

            if (value is CheckBox)
                return new CheckBoxProxy(value as CheckBox);

            if (value is DatePicker)
                return new DatePickerProxy(value as DatePicker);

            if (value is ComboBox)
                return new ComboBoxProxy(value as ComboBox);

            if (value is Expander)
                return new ExpanderProxy(value as Expander);

            if (value is RadioButton)
                return new RadioButtonProxy(value as RadioButton);

            if (value is ListView)
                return new ListViewProxy(value as ListView);

            if (value is Choice)
                return new ChoiceProxy(value as Choice);

            if (value is GroupBox)
                return new GroupBoxProxy(value as GroupBox);

            if (value is CloseButton || value is GroupMembersButton)
            {
                Button btn = UIHelper.FindFirstChild<Button>(value as DependencyObject, false);
                if (btn != null)
                {
                    return new ButtonProxy(btn);
                }
            }

            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
Sr. application developer currently developing desktop and web applications for the specialty insurance sector. Data integration specialist, interested in learning the latest .Net technologies.

Comments and Discussions