|
<Window x:Class="ObjectPresentation.Examples.Client.ValuePresenterExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ObjectPresentation="clr-namespace:ObjectPresentation;assembly=ObjectPresentation"
xmlns:local="clr-namespace:ObjectPresentation.Examples.Client"
SizeToContent="WidthAndHeight" MaxHeight="600"
Title="ValuePresenter example" >
<Window.Resources>
<DataTemplate DataType="{x:Type local:MyRectangle}">
<Canvas>
<Rectangle Canvas.Top="{Binding Top}"
Canvas.Left="{Binding Left}"
StrokeThickness="{Binding StrokeThickness}"
Width="{Binding Width}"
Height="{Binding Height}" >
<Rectangle.Fill>
<SolidColorBrush Color="{Binding FillColor}" />
</Rectangle.Fill>
<Rectangle.Stroke>
<SolidColorBrush Color="{Binding StrokeColor}" />
</Rectangle.Stroke>
</Rectangle>
</Canvas>
</DataTemplate>
<DataTemplate DataType="{x:Type local:MyCircle}">
<Canvas>
<Ellipse Canvas.Top="{Binding Top}"
Canvas.Left="{Binding Left}"
StrokeThickness="{Binding StrokeThickness}"
Width="{Binding Diameter}"
Height="{Binding Diameter}" >
<Ellipse.Fill>
<SolidColorBrush Color="{Binding FillColor}" />
</Ellipse.Fill>
<Ellipse.Stroke>
<SolidColorBrush Color="{Binding StrokeColor}" />
</Ellipse.Stroke>
</Ellipse>
</Canvas>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.Resources>
<x:ArrayExtension x:Key="typeDataTemplates" Type="{x:Type ObjectPresentation:TypeDataTemplate}">
<ObjectPresentation:TypeDataTemplate ValueType="{x:Type Color}">
<ObjectPresentation:TypeDataTemplate.ValueViewModelDataTemplate>
<DataTemplate>
<local:ColorPicker Width="150"
SelectedColor="{Binding Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</ObjectPresentation:TypeDataTemplate.ValueViewModelDataTemplate>
</ObjectPresentation:TypeDataTemplate>
</x:ArrayExtension>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="300"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ContentControl Name="myContent"
Content="{Binding ElementName=vp, Path=Value, Mode=TwoWay}" />
<Border Grid.Column="1"
BorderBrush="Blue"
BorderThickness="2"
Background="LightBlue"
CornerRadius="5"
Margin="5" Padding="5">
<ObjectPresentation:ValuePresenter x:Name="vp"
ValueType="{x:Type local:MyShape}"
DataTemplates="{StaticResource typeDataTemplates}" />
</Border>
</Grid>
</Window>
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.