WPF Recursion Controls
WPF Recursion Controls presents a simple language for drawing pictures that illustrates
the power of data abstraction and closure, and also exploits higher-order procedures
in an essential way. The language is designed to make it easy to experiment with
patterns such as the ones in figure , which are composed of repeated elements that
are shifted and scaled. In this language, the data objects being combined are represented
as procedures rather than as list structure.
The source: http://mitpress.mit.edu/sicp/full-text/sicp/book/node36.html
Resource Page DescriptionWPF Recursion Controls is a sample to the power of WPF.
Please take look at this code and try to build your image. ( See samples on the home page)
I would like to get comments.
Beside Sample:
The XAML code:
<E4D:Beside Width="512" Height="256" Content="Beside">
<!-- Can be any UIElement-->
<Image Source="..\Images\E4D.png" Stretch="Fill"/>
</E4D:Beside>
The Function code:
public static UIElement Below( this UIElement source )
{
UIElement cloned = source.Clone();
return Below( source, cloned );
}
public static UIElement Below( this UIElement source, UIElement element )
{
Grid g = new Grid();
RowDefinition r1 = new RowDefinition ();
r1.Height = new GridLength ( 0.5 , GridUnitType.Star );
RowDefinition r2 = new RowDefinition();
r2.Height = new GridLength ( 0.5 , GridUnitType.Star );
g.RowDefinitions.Add( r1 );
g.RowDefinitions.Add( r2 );
g.ShowGridLines = ShowGridLines;
g.Children.Add( source );
g.Children.Add( element );
Grid.SetRow( source, 0 );
Grid.SetRow( element, 1 );
return g;
}
The Result in Blend
More Sample: