FrameworkElement.Parent property null when used in a template
Posted: 11 Jul 2017, 01:16
I'm having an issue where I have a custom control registering to events on the parent element, and sending it on a message bus type architecture.
Everything works fine, except when I am using this custom control inside a template: In this case, the property 'Parent' in the codebehind is null and never set.
Am I doing something wrong? Where could the issue be?
Thanks a lot,
Pierre
Everything works fine, except when I am using this custom control inside a template: In this case, the property 'Parent' in the codebehind is null and never set.
Code: Select all
<Expander ExpandDirection="Up" Grid.Column="1" Header="THINGS" VerticalAlignment="Bottom">
<ItemsControl ItemsSource="{Binding BottomMenuBarViewModels}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type vm:BottomMenuBarViewModel}">
<Border>
<Button>
<views:MessagingView Event="Click">
Send message!
</views:MessagingView >
</Button>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Expander>
Thanks a lot,
Pierre