tags:

views:

418

answers:

0

I have custom Bitmap object that is within a styled button. I am trying to call PresentationSource.FromVisual within the Bitmap object however it is returning null.

How would I get the Parent element (in this case a Button) from within the child Bitmap object. Is there standard code to get the styled parent?

For example the WPF style is as follows:

<StackPanel Orientation="Horizontal">
 <ContentPresenter Margin="3,-2,3,1" VerticalAlignment="Center"/>
 <local:Bitmap Source="Images\Image.png"/>
</StackPanel>

I would like the Bitmap object to be able to get the styled parent element or Windows in all circumstances.

Luke