Here's a simple demo of what's going on - just a xaml & c# file - nothing complicated.
<Window x:Class="WizardItemsSourceTest.Window1" Name="WizTester"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
xmlns:wizard="http://schemas.actiprosoftware.com/winfx/xaml/wizard"
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
Title="Window1" Height="300" Width="500">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Button Content="LoadWizard2" Click="LoadWizard2_Click"/>
</StackPanel>
<StackPanel Orientation="Vertical">
<wizard:Wizard x:Name="wizard1"
WindowTitleBaseText="Wizard1 - Load Via ItemSource"
ItemsSource="{Binding ElementName=WizTester, Path=WizardPages, diag:PresentationTraceSources.TraceLevel=High}"
>
</wizard:Wizard>
<wizard:Wizard x:Name="wizard2"
WindowTitleBaseText="Wizard2 - Load Manually"
>
</wizard:Wizard>
</StackPanel>
</StackPanel>
</Window>
and here's the code behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using ActiproSoftware.Windows.Controls.Wizard;
using System.ComponentModel;
namespace WizardItemsSourceTest
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public List<WizardPage> WizardPages
{
get { return (List<WizardPage>)GetValue(WizardPagesProperty); }
set { SetValue(WizardPagesProperty, value); }
}
public static readonly DependencyProperty WizardPagesProperty =
DependencyProperty.Register("WizardPages", typeof(List<WizardPage>), typeof(Window1), new UIPropertyMetadata(new List<WizardPage>()));
public Window1()
{
InitializeComponent();
LoadPages();
}
private void LoadPages()
{
List<WizardPage> wp = new List<WizardPage>();
for (int x = 0; x < 3; x++)
{
WizardPage newPage = new WizardPage();
newPage.Content = "This is page " + x;
newPage.MinHeight = 10;
wp.Add(newPage);
}
WizardPages = wp;
}
private void LoadWizard2_Click(object sender, RoutedEventArgs e)
{
List<WizardPage> wp = new List<WizardPage>();
for (int x = 0; x < 3; x++)
{
WizardPage newPage = new WizardPage();
newPage.Content = "This is page " + x;
wizard2.Items.Add(newPage);
}
}
}
}
The error that I'm getting in the output when attempting to bind to the itemssource is:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ActiproSoftware.Windows.Controls.Wizard.Wizard', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'Grid' (Name='PART_Header'); target property is 'MinHeight' (type 'Double')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ActiproSoftware.Windows.Controls.Wizard.Wizard', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'Grid' (Name='PART_Header'); target property is 'MinHeight' (type 'Double')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ActiproSoftware.Windows.Controls.Wizard.Wizard', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'Grid' (Name='PART_Header'); target property is 'MinHeight' (type 'Double')
It looks as if the errors are internal (unless I'm missing something).
Thanks,
Mark