Click here to Skip to main content
15,894,646 members
Articles / Desktop Programming / WPF

Quickly Generate and Use Dynamic Class

Rate me:
Please Sign up or sign in to vote.
3.64/5 (9 votes)
15 Sep 2010CPOL4 min read 63.8K   2.8K   34  
Quickly show you how to create and use a dynamic type/class
  • srcdynamicdemo.zip
  • dynamicdemo.zip
    • DynamicType.sln
    • bin
      • DynamicType.Web.dll
      • DynamicType.Web.pdb
      • ClientBin
        • DynamicType.xap
        • DynamicType.Web.csproj
        • DynamicType.Web.csproj.user
        • DynamicTypeTestPage.aspx
        • DynamicTypeTestPage.html
        • AssemblyInfo.cs
        • Silverlight.js
        • Web.config
        • Web.Debug.config
        • Web.Release.config
        • App.xaml
        • App.xaml.cs
        • Bin
          • Debug
            • AppManifest.xaml
            • ar
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • bg
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • ca
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • cs
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • da
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • de
              • Microsoft.CSharp.resources.dll
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
              • System.Xml.Linq.resources.dll
            • DevExpress.AgDataGrid.v8.2.dll
            • DevExpress.AgDataGrid.v8.2.xml
            • DynamicType.dll
            • DynamicType.xap
            • DynamicTypeTestPage.html
            • el
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • es
              • Microsoft.CSharp.resources.dll
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
              • System.Xml.Linq.resources.dll
            • et
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • eu
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • fi
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • fr
              • Microsoft.CSharp.resources.dll
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
              • System.Xml.Linq.resources.dll
            • he
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • hr
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • hu
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • id
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • it
              • Microsoft.CSharp.resources.dll
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
              • System.Xml.Linq.resources.dll
            • ja
              • Microsoft.CSharp.resources.dll
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
              • System.Xml.Linq.resources.dll
            • ko
              • Microsoft.CSharp.resources.dll
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
              • System.Xml.Linq.resources.dll
            • lt
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • lv
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • Microsoft.CSharp.dll
            • Microsoft.CSharp.xml
            • ms
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • nl
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • no
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • pl
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • pt
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • pt-BR
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • ro
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • ru
              • Microsoft.CSharp.resources.dll
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
              • System.Xml.Linq.resources.dll
            • sk
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • sl
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • sr-Cyrl-CS
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • sr-Latn-CS
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • sv
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • System.ComponentModel.DataAnnotations.dll
            • System.ComponentModel.DataAnnotations.xml
            • System.Windows.Controls.Data.dll
            • System.Windows.Controls.Data.Input.dll
            • System.Windows.Controls.Data.Input.xml
            • System.Windows.Controls.Data.xml
            • System.Windows.Controls.dll
            • System.Windows.Controls.xml
            • System.Windows.Data.dll
            • System.Windows.Data.xml
            • System.Xml.Linq.dll
            • System.Xml.Linq.xml
            • th
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • tr
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • uk
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • vi
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
            • zh-Hans
              • Microsoft.CSharp.resources.dll
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
              • System.Xml.Linq.resources.dll
            • zh-Hant
              • Microsoft.CSharp.resources.dll
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
              • System.Xml.Linq.resources.dll
        • DynamicBuilder.cs
        • DynamicDemo.cs
        • DynamicType.csproj
        • DynamicType.csproj.user
        • Lib
        • MainPage.xaml
        • MainPage.xaml.cs
        • AppManifest.xml
        • AssemblyInfo.cs
<UserControl x:Class="DynamicType.MainPage"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
			 xmlns:dx="clr-namespace:DevExpress.AgDataGrid;assembly=DevExpress.AgDataGrid.v8.2"
			 mc:Ignorable="d"
			 FontSize="14"
			 d:DesignHeight="300" d:DesignWidth="300"
			 Loaded="UserControl_Loaded"
			 >

    <Grid x:Name="LayoutRoot" Background="White">
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto"></ColumnDefinition>
			<ColumnDefinition></ColumnDefinition>
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"></RowDefinition>
			<RowDefinition></RowDefinition>
		</Grid.RowDefinitions>
		<Border BorderBrush="Orange" BorderThickness="2" Padding="3" Margin="5,15">
			<StackPanel Orientation="Vertical"
									Margin="7,2,2,2"
									HorizontalAlignment="Stretch"
									VerticalAlignment="Top"
									Grid.Column="0"
									Grid.Row="0">
				<TextBlock Text="Select your poison(s)"></TextBlock>
				<Rectangle Height="1" Fill="Gray" Margin="0,0,0,20"></Rectangle>
				<ItemsControl ItemsSource="{Binding PropertysList}" Margin="1">
					<ItemsControl.ItemTemplate>
						<DataTemplate>
							<CheckBox Content="{Binding Name}"
									  Click="CheckBox_Click"
									  Tag="{Binding}"
									  Margin="0,5">
							</CheckBox>
						</DataTemplate>
					</ItemsControl.ItemTemplate>
				</ItemsControl>
			</StackPanel>
		</Border>
		<Button Grid.Column="0"
				VerticalAlignment="Top"
				Grid.Row="1"
				Margin="5,20"
				Height="25"
				MinWidth="100"
				Content="Submit"
				Click="SubmitButton_Click"
				>
		</Button>
		<dx:AgDataGrid AutoGenerateColumns="True"
					   x:Name="devGrid"
					   ColumnsAutoWidth="True"
					   Grid.Column="1" 
					   Grid.Row="0"
					   Grid.RowSpan="2"
					   Margin="5"
					   HorizontalAlignment="Stretch"
					   VerticalAlignment="Stretch">
		</dx:AgDataGrid>
	</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
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions