Using the superb WPF Diagram Designer by sukram on CodeProject.
Trying to taylor the code to my own use. In particular been trying to specify a Xaml DataTemplate for the ToolBoxItem which is a custom control based on ContentControl.
Inside the ToolBox which is itself a custom control based on the ItemsControl when I specify a ItemTemplate and point it at my DataTemplate it fails. Found I needed to add a ContentTemplate to the style and make it a TemplateBinding to the ContentControl.ContentTemplate, hence
<Style TargetType="{x:Type cc:ToolboxItem}">
<Setter Property="Control.Padding" Value="5" />
<Setter Property="ContentControl.HorizontalContentAlignment" Value="Stretch" />
<Setter Property="ContentControl.VerticalContentAlignment" Value="Stretch" />
<Setter Property="ToolTip" Value="{Binding ToolTip}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type cc:ToolboxItem}">
<Grid>
<Rectangle Name="Border" StrokeThickness="1" StrokeDashArray="2" Fill="Transparent"
SnapsToDevicePixels="true" />
<ContentPresenter Content="{TemplateBinding ContentControl.Content}"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
then I can specify the DataTemplate inside my ToolBox (ItemsControl) using ItemTemplate="{StaticResource designItemDataTemplate}"
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment