Visual Basic (Declaration) | |
---|---|
Public Class NodePanel Inherits System.Windows.Controls.Panel Implements ISupportInitialize, IFrameworkInputElement, IInputElement, IAddChild, IQueryAmbient, IAnimatable |
C# | |
---|---|
public class NodePanel : System.Windows.Controls.Panel, ISupportInitialize, IFrameworkInputElement, IInputElement, IAddChild, IQueryAmbient, IAnimatable |
A NodePanel
is typically used as the implementation of a Node's DataTemplate
when you want the node to basically be some shape (a "figure", but it can be any kind of UIElement
) and you want to position and align additional elements within that primary shape. If you want elements such as text outside of that shape, we suggest you use a Panel
such as StackPanel
or Grid
to arrange the node the way you want.
The first child element of the panel is treated as the main object. It can have two attached property values, NodePanel.Spot1
and NodePanel.Spot2
, that denote the top-left and bottom-right corners of an area where the other child elements are placed. The default spot values will just cover the whole element. However, a NodeShape
(WPF), or a Path
(Silverlight), with a NodeFigure
attached property is frequently used as the first element of a NodePanel
. Such shapes have predefined Spot1
and Spot2
values in addition to having particular geometries.
The layout will observe the FrameworkElement.HorizontalAlignment
and VerticalAlignment
properties of each child element after the first one.
As an example, here is the definition of a simple template that displays a resizable rounded rectangle surrounding some text:
<DataTemplate x:Key="ExampleNodeTemplate"> <go:NodePanel go:Node.Location="{Binding Path=Data.XY, Mode=TwoWay}" go:Node.SelectionElementName="Shape" go:Node.Resizable="True"> <go:NodeShape x:Name="Shape" go:NodePanel.Figure="RoundedRectangle" Width="50" Height="20" Stroke="Gray" StrokeThickness="1" Fill="LightYellow" /> <TextBlock Text="{Binding Path=Data.Name}" TextWrapping="Wrap" /> </go:NodePanel> </DataTemplate>In WPF, you must use the
<go:NodeShape>
element instead of a <Path>
element. In Silverlight, you may use either the <go:NodeShape>
element or a <Path>
element.
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Visual
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Panel
Northwoods.GoXam.NodePanel