Hey there,
simple task big problem:
I have a hierachicalDataTemplate for an ORM Object , so foar so good all of the normal Properies like Name(String) or Note(string) a bound and even a simple Property in a EntityRef like Customer.Name gets bound but if I try to bind a IEnumerable of the Customer to a Combobox in the HierarichalDataTemplate I get a binding error. The Debugger tells me there is no Property but there is and its perfectly filled with values.
If someone have a hint for me on that it would be cool, here are my template and the interface definition
<!-- TourPosition Template --><HierarchicalDataTemplate DataType="{x:Type Interfaces:ITourPosition}" x:Key="TourPositionItem"><Grid DataContext="{Binding }"><Grid.ColumnDefinitions><ColumnDefinition Width="Auto" /><ColumnDefinition Width="Auto" /><ColumnDefinition Width="Auto" /><ColumnDefinition Width="Auto" /><ColumnDefinition Width="Auto" /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="Auto" /></Grid.RowDefinitions><!-- Order --><TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding Order}" Background="Transparent" Margin="5" Foreground="White" Width="50" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="10" FontWeight="Normal"/><!-- Customer Name --><TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Customer.Name}" Background="Transparent" Margin="5" Foreground="White" Width="150" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="10" FontWeight="Normal"/><!-- Customer DeliveryAddress --><ComboBox Grid.Row="0" Grid.Column="2" SelectedValuePath="Content" BorderThickness="1" BorderBrush="{MyStyles:MyStyleRef ResourceKey=ForegroundBorderBrush}" ItemsSource="{Binding Customer.DeliveryAddresses}" ItemTemplate="{MyStyles:MyTemplateRef ResourceKey=AddressItem}" SelectedItem="{Binding Address,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Style="{MyStyles:MyStyleRef ResourceKey=MyComboBoxStyle}" Name="cbAddress" Margin="10,5,5,5" VerticalAlignment="Center"></ComboBox><!-- Note --><TextBox Grid.Row="0" Grid.Column="3" Text="{Binding Note,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Style="{MyStyles:MyStyleRef ResourceKey=MyTextBoxStyle}" TextWrapping="Wrap" Background="Transparent" Margin="5" SelectionBrush="{MyStyles:MyStyleRef ResourceKey=MySelectionBrush}" BorderBrush="{MyStyles:MyStyleRef ResourceKey=ForegroundBorderBrush}" Foreground="White" HorizontalContentAlignment="Stretch" MinWidth="200" MaxWidth="200" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="10" FontWeight="Normal" CaretBrush="White"/><!-- Delete Button--><Button Grid.Row="0" Grid.Column="4" Content="-" Margin="10,5,5,5" Style="{MyStyles:MyStyleRef ResourceKey=MyButtonStyle}" Command="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type UserControl}},Path=DataContext.DeleteTourPositionCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Grid}},Path=DataContext}"/></Grid></HierarchicalDataTemplate>
public interface ITourPosition { Int64 ID { get; } ICustomer Customer { get; set; } string Note { get; set; } int Order { get; set; } ITour Tour { get; set; } IAddress Address { get; set; } } public interface ICustomer { IEnumerable<IEmail> CustomerEmail { get; } IEnumerable <IFax> CustomerFax { get; } IEnumerable <IPhone> CustomerPhone { get; } IEnumerable <IAddress> DeliveryAddresses { get; } IEnumerable <IDeliveryOrder > DeliveryOrder { get; } decimal? Discount { get; set; } IEnumerable <IInvoice> Invoice { get; } IEnumerable <IAddress> InvoiceAddress { get; } string Name { get; set; } string Note { get; set; } string Number { get; set; } Int64 ID { get; } IEnumerable <ICustomerPawn> Pawn { get; } IEnumerable <ITour> Tour { get; } IEmail MainEmail { get; } IFax MainFax { get; } IPhone MainPhone { get; } IAddress MainDeliveryAddress { get; } IAddress MainInvoiceAddress { get; } }
regards
Markus