I have a UserControl that contains a menu. I need to bind Menu.Icon to the UserControl property, but it does not work.
The code starts as follows:
<Border Grid.Row="0">
<DockPanel>
<Image x:Name="testImage" Height="16" Width="16" Source="{Binding ElementName=UC,Path=AddImage}"/>
<Menu DockPanel.Dock="Left" Height="20"
VerticalAlignment="Center">
<MenuItem Header="{Binding ElementName=UC,Path=AddText}">
<MenuItem.Icon>
<Image x:Name="realImage" Height="16" Width="16"
Source="{Binding ElementName=UC,Path=AddImage}"/>
</MenuItem.Icon>
</MenuItem>
The first image that you see declared (testImage) works fine, so I'm glad the binding is correct. The second image (commented out and named "workswhenin") contains the URI of the package that I pass to the UserControls binding property, and this also works, but the third (realImage) does not appear at all!
I do not see ANY reason why this should not work; I know that snapping is good, and I know that placing images in markup is good, so what happens?
Any help would be greatly appreciated. Thanks in advance.