Click here to Skip to main content
15,886,742 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.
<UserControl x:Class="WPFFormDesigner.PropertiesView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:WpfPropertyGrid="clr-namespace:System.Windows.Controls.WpfPropertyGrid;assembly=System.Windows.Controls.WpfPropertyGrid" xmlns:Design="clr-namespace:System.Windows.Controls.WpfPropertyGrid.Design;assembly=System.Windows.Controls.WpfPropertyGrid" xmlns:Themes="clr-namespace:System.Windows.Controls.WpfPropertyGrid.Themes;assembly=System.Windows.Controls.WpfPropertyGrid.Themes" xmlns:WPFPropertyGridProxies="clr-namespace:WPFFormDesigner.WPFPropertyGridProxies" xmlns:ViewModels="clr-namespace:WPFFormDesigner.ViewModels" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300" DataContextChanged="UserControl_DataContextChanged">
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*" />
		</Grid.ColumnDefinitions>
		<!--<xctk:PropertyGrid x:Name="_propertyGrid" AutoGenerateProperties="True"
                           ShowAdvancedOptions="True" SelectedObject="{StaticResource MyButton}">
        </xctk:PropertyGrid>-->
		<ScrollViewer Name="PropertiesViewScrollViewer" Background="Transparent" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Grid.Row="0" Grid.Column="0">
			<WpfPropertyGrid:PropertyGrid x:Name="propertyGrid" Grid.Column="1" PropertyDisplayMode="All" ShowAttachedProperties="False" ShowReadOnlyProperties="True">
				<!--SelectedObject="{StaticResource MyButton}">-->
				<WpfPropertyGrid:PropertyGrid.Resources>
					<ResourceDictionary>
						<ResourceDictionary.MergedDictionaries>
							<Themes:KaxamlTheme />
						</ResourceDictionary.MergedDictionaries>
					</ResourceDictionary>
				</WpfPropertyGrid:PropertyGrid.Resources>
				<!-- Very important! Extended Property Editors 
            require a TabbedLayout to be defined, otherwise the commands won't work!!-->
				<WpfPropertyGrid:PropertyGrid.Layout>
					<Design:TabbedLayout>
						<Design:TabbedLayoutItem Header="Categorized" CanClose="False">
							<Design:CategorizedLayout />
						</Design:TabbedLayoutItem>
						<Design:TabbedLayoutItem Header="Alphabetical" CanClose="False">
							<Design:AlphabeticalLayout />
						</Design:TabbedLayoutItem>
					</Design:TabbedLayout>
				</WpfPropertyGrid:PropertyGrid.Layout>
				<!--<WpfPropertyGrid:PropertyGrid.Editors>
                <WpfPropertyGrid:CategoryEditor DeclaringType="{x:Type BrushProxy}"
                          CategoryName="Brushes"
                          InlineTemplate="{StaticResource  mydata}"/>
            </WpfPropertyGrid:PropertyGrid.Editors>-->
				<!--<WpfPropertyGrid:PropertyGrid.Editors>
                <WpfPropertyGrid:PropertyEditor DeclaringType="{x:Type Button}" PropertyName="Content" InlineTemplate="{StaticResource TextEditor_Inline}" ExtendedTemplate="{StaticResource TextEditor_Extended}"/>
            </WpfPropertyGrid:PropertyGrid.Editors>-->
				<WpfPropertyGrid:PropertyGrid.Editors>
					<WpfPropertyGrid:PropertyEditor DeclaringType="{x:Type WPFPropertyGridProxies:TextBoxProxy}" PropertyName="Text" InlineTemplate="{StaticResource TextProxyEditor_Inline}" ExtendedTemplate="{StaticResource TextProxyEditor_Extended}" />
					<WpfPropertyGrid:PropertyEditor DeclaringType="{x:Type WPFPropertyGridProxies:CheckBoxProxy}" PropertyName="IsChecked" InlineTemplate="{StaticResource TextProxyEditor_Inline}" ExtendedTemplate="{StaticResource TextProxyEditor_Extended}" />
					<WpfPropertyGrid:PropertyEditor DeclaringType="{x:Type WPFPropertyGridProxies:DatePickerProxy}" PropertyName="SelectedDate" InlineTemplate="{StaticResource TextProxyEditor_Inline}" ExtendedTemplate="{StaticResource TextProxyEditor_Extended}" />
					<WpfPropertyGrid:PropertyEditor DeclaringType="{x:Type WPFPropertyGridProxies:ComboBoxProxy}" PropertyName="ItemsSource" InlineTemplate="{StaticResource TextProxyEditor_Inline}" ExtendedTemplate="{StaticResource TextProxyEditor_Extended}" />
					<WpfPropertyGrid:PropertyEditor DeclaringType="{x:Type WPFPropertyGridProxies:ComboBoxProxy}" PropertyName="SelectedValue" InlineTemplate="{StaticResource TextProxyEditor_Inline}" ExtendedTemplate="{StaticResource TextProxyEditor_Extended}" />
					<WpfPropertyGrid:PropertyEditor DeclaringType="{x:Type WPFPropertyGridProxies:ListViewProxy}" PropertyName="Columns" InlineTemplate="{StaticResource ListViewProxy_Columns_Inline}" ExtendedTemplate="{StaticResource ListViewProxy_Columns_Extended}" />
					<WpfPropertyGrid:PropertyEditor DeclaringType="{x:Type WPFPropertyGridProxies:ListViewProxy}" PropertyName="ItemsSource" InlineTemplate="{StaticResource ListViewProxy_Columns_Inline}" ExtendedTemplate="{StaticResource TextProxyEditor_Extended}" />
					<WpfPropertyGrid:PropertyEditor DeclaringType="{x:Type WPFPropertyGridProxies:ListViewProxy}" PropertyName="SelectedItem" InlineTemplate="{StaticResource ListViewProxy_Columns_Inline}" ExtendedTemplate="{StaticResource TextProxyEditor_Extended}" />
					<WpfPropertyGrid:PropertyEditor DeclaringType="{x:Type WPFPropertyGridProxies:ExpanderProxy}" PropertyName="AddListViewVisibilityConverter" InlineTemplate="{StaticResource ExpanderProxyVisibilityFlagEditor_Inline}" />
				</WpfPropertyGrid:PropertyGrid.Editors>
			</WpfPropertyGrid:PropertyGrid>
		</ScrollViewer>
	</Grid>
</UserControl>

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