Thanks for the quick response! I did what you suggested. I created a custom view model, moved to a ContentTemplate, and added an ItemAdded method. It does not appear as if the Bindings in the DataTemplate are being used. Neither the stencil nor the "dropped" node in the diagram show the items in the data template. I'm wondering if we need to set the DataContext for the Node somewhere like other WPF controls. However, that property doesn't seem to exist here.
Here's the DataTemplate
'<DataTemplate x:Key="LogicBlock">
<Border BorderThickness="2" BorderBrush="Black">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding LogicBlockName}" FontSize="10" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="0" Grid.Column="0"/>
<Image Source="{Binding LogicImage}" Width="50" Height="50" HorizontalAlignment="Right" Stretch="Fill" RenderOptions.BitmapScalingMode="Fant"
Grid.Row="0" Grid.Column="1" />
</Grid>
</Border>
</DataTemplate>'
Here's the definition of the Symbol in the Stencil.
'<local:VfSymbolCollection>
<!--Define the DiagramElement-Node-->
<!--<local:VfGHAViewModel x:Name="GHAObject" UnitHeight="100" UnitWidth="100" OffsetX="100" OffsetY="100"
Shape="{StaticResource Rectangle }" Key="GHAObjects">
</local:VfGHAViewModel>-->
<local:VfLogicViewModel x:Name="ANDBlock" UnitHeight="100" UnitWidth="100" CustomContentTemplate="LogicBlock"
Shape="{StaticResource Rectangle }" Key="Logic" LogicBlockName="AND" LogicImagePath="/Images/Logic_AND.png"
ContentTemplate="{StaticResource LogicBlock}">'
And here's the custom NodeViewModel
'public class VfLogicViewModel : NodeViewModel
{
private string _logicBlockName;
[DataMember]
public string LogicBlockName
{
get
{
return _logicBlockName;
}
set
{
if (value != _logicBlockName)
{
_logicBlockName = value;
OnPropertyChanged("LogicBlockName");
}
}
}
private string _logicImagePath;
[DataMember]
public string LogicImagePath
{
get
{
return _logicImagePath;
}
set
{
if (value != _logicImagePath)
{
_logicImagePath = value;
LogicImage = new Image();
LogicImage.Source = new BitmapImage(new Uri(_logicImagePath,UriKind.Relative));
OnPropertyChanged("LogicImagePath");
OnPropertyChanged("LogicImage");
}
}
}
public Image LogicImage { get ; set; }
private string _customcontenttemplate;
[DataMember]
public string CustomContentTemplate
{
get
{
return _customcontenttemplate;
}
set
{
if (value != _customcontenttemplate)
{
_customcontenttemplate = value;
OnPropertyChanged("CustomContentTemplate");
}
}
}
public VfLogicViewModel() : base ()
{
}
}'