Hi,
When i try to export diagram that contains templated ShapeNodes
there is a problem with rendering a DataBinded properties.
<Window x:Class="Diagraming.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Diagraming"
xmlns:diagram="http://mindfusion.eu/diagramming/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button Content="Export to PDF" Grid.Row="0" Click="ExportToPdf_Click"></Button>
<diagram:DiagramView x:Name="diagram" Grid.Row="1">
<diagram:DiagramView.Resources>
<Style TargetType="{x:Type diagram:ShapeNode}">
<Setter Property="Template">
<Setter.Value>
<DataTemplate>
<Label Background="Yellow" Content="{Binding Text, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"></Label>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</diagram:DiagramView.Resources>
</diagram:DiagramView>
</Grid>
</Window>
namespace Diagraming
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window, INotifyPropertyChanged
{
[field: NonSerialized]
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
public Diagram diag { get; set; }
private string text;
public String Text
{
get
{
return text;
}
set
{
text = value;
NotifyPropertyChanged("Text");
}
}
public MainWindow()
{
InitializeComponent();
this.DataContext = this;
Text = "Test";
diag = new Diagram();
diag.Nodes.Add(new ShapeNode()
{
Shape = new Shape(new ElementTemplate[]
{
new LineTemplate(0, 0, 100, 0),
new LineTemplate(100, 0, 100, 100),
new LineTemplate(100, 100, 0, 100),
}, FillRule.EvenOdd),
});
diag.Nodes.Last().Move(50, 25);
diagram.Diagram = diag;
}
private void ExportToPdf_Click(object sender, RoutedEventArgs e)
{
var exporter = new PdfExporter();
//foreach (var diag in diagrams)
exporter.Export(diag, @"D:\temp\diagram.pdf");
}
}
}