I have other strange effects as you can see in Part5.
After the rotation I can’t resize the node as expected.
My have no idea how my template can be responsible for this.
Since I have many different elements to display in the nodes, I’ve made a style with all the major bindings.
<Style x:Key="ElementGridStyle" TargetType="{x:Type Grid}">
<Setter Property="go:Part.Resizable" Value="{Binding Path=Part.Diagram.DataContext.EditMode}"/>
<Setter Property="go:Part.SelectionAdorned" Value="False" />
<Setter Property="go:Node.ZOrder" Value="{Binding Path=Data.Z}" />
<Setter Property="go:Part.Movable" Value="{Binding Path=Data.IsMovable}" />
<Setter Property="go:Part.Selectable" Value="{Binding Path=Data.IsSelectable}" />
<Setter Property="go:Part.Deletable" Value="{Binding Path=Data.IsDeletable}" />
<Setter Property="go:Part.Rotatable" Value="{Binding Path=Data.IsRotatable}" />
<Setter Property="Width" Value="{Binding Path=Data.Width, Mode=TwoWay}" />
<Setter Property="Height" Value="{Binding Path=Data.Height, Mode=TwoWay}" />
<Setter Property="Opacity" Value="{Binding Path=Data.Opacity}" />
<Setter Property="Visibility" Value="{Binding Path=Data.Visibility}" />
<Setter Property="Background" Value="{Binding Path=Part.Diagram.DataContext.EditMode, Converter={StaticResource IsEditModeBackgroundConverter}}" />
<Setter Property="Tag" Value="{Binding Part.Diagram}" />
<Setter Property="go:Node.LocationSpot" Value="TopLeft" />
<Setter Property="go:Node.RotationSpot" Value="Center" />
<Setter Property="go:Node.Location">
<Setter.Value>
<MultiBinding Converter="{StaticResource PosToPointConverter}" Mode="TwoWay">
<Binding Path="Data.X" Mode="TwoWay" />
<Binding Path="Data.Y" Mode="TwoWay" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="go:Node.RotationAngle" Value="{Binding Path=Data.Angle, Mode=TwoWay}" />
<Setter Property="ContextMenu" Value="{StaticResource ElementContextMenu}" />
<Setter Property="ToolTip" Value="{x:Null}" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Part.Diagram.DataContext.EditMode}" Value="True">
<Setter Property="ToolTip" Value="{Binding Path=Data.Description}" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=Part.Diagram.DataContext.EditMode}" Value="False">
<Setter Property="ContextMenu" Value="{x:Null}" />
</DataTrigger>
<Trigger Property="ToolTip" Value="{x:Static system:String.Empty}">
<Setter Property="ToolTipService.IsEnabled" Value="False" />
</Trigger>
</Style.Triggers>
</Style>
Then for the element you can see in the videos there is a datatemplate:
<DataTemplate x:Key="SimpleButton" DataType="{x:Type classes:Element}">
<Grid Style="{StaticResource ElementGridStyle}">
<Button x:Name="button" Style="{StaticResource KeyboardButtonStyle}"
Visibility="{Binding Path=Data.NoDisplay, Converter={StaticResource BooleanToVisibilityConverterInverse}}"
IsHitTestVisible="{Binding Path=Part.Diagram.DataContext.EditMode, Converter={StaticResource BooleanNegationConverter}}"
Background="{Binding Path=Data.BackgroundBrush}"
BorderBrush="{Binding Path=Data.BorderColor, Converter={StaticResource ColorToBrushConverter}}"
Foreground="{Binding Path=Data.ForegroundColor, Converter={StaticResource ColorToBrushConverter}}"
HorizontalContentAlignment="{Binding Path=Data.Horizontal}"
VerticalContentAlignment="{Binding Path=Data.Vertical}"
Padding="2"
FontSize="{Binding Path=Data.FontSize}"
FontFamily="{Binding Path=Data.FontFamily, TargetNullValue='Segoe UI'}"
>
<TextBlock Text="{Binding Path=Data.Text}" TextWrapping="{Binding Data.Wrap, Converter={StaticResource WrapConverter}}" />
</Button>
<ContentControl Template="{StaticResource PlaceholderTemplate}" />
<ToggleButton x:Name="PinnedButton" Style="{StaticResource PinnedToggleButton}" Opacity="0" />
<ToggleButton x:Name="QuickZoomButton" Style="{StaticResource QuickZoomToggleButton}" Opacity="0" />
<Button x:Name="SettingButton" Style="{StaticResource SettingButton}" Opacity="0" />
<Border Style="{StaticResource MarkerBorderStyle}" Visibility="{Binding Path=Data.IsMarked, Converter={StaticResource BooleanToVisibilityConverter}}"/>
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=Data.IsSelected}" Value="True">
<Setter TargetName="button" Property="Background" Value="{Binding Path=Data.BackgroundBrushSelected}" />
<Setter TargetName="button" Property="BorderBrush" Value="{Binding Path=Data.BorderColorSelected, Converter={StaticResource ColorToBrushConverter}}" />
<Setter TargetName="button" Property="Foreground" Value="{Binding Path=Data.ForegroundColorSelected, Converter={StaticResource ColorToBrushConverter}}" />
</DataTrigger>
<Trigger Property="Button.IsMouseOver" Value="True">
<Setter TargetName="PinnedButton" Property="Opacity" Value="1"></Setter>
<Setter TargetName="QuickZoomButton" Property="Opacity" Value="1"></Setter>
<Setter TargetName="SettingButton" Property="Opacity" Value="1"></Setter>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>