tags:

views:

61

answers:

1

I am very new to WPF and I am a bit stuck. I'm trying to create a demo program that displays several embedded win forms applications. I'd like to add a reflection of the form, but most of the existing tutorials I've seen seen for image reflections do not work. If anyone can point me in the right direction I would really appreciate it.

Here is the relevent xaml - the form control is added to the embedForm stack panel dynamically.

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Border Name="inkBorder" Grid.Row="0" VerticalAlignment="Bottom" Margin="20"
            Width="400" Height="500" CornerRadius="5" BorderThickness="4">
                <Border.BorderBrush>
                    <LinearGradientBrush SpreadMethod="Reflect" StartPoint="0,0" EndPoint="0.5,0.5">
                        <LinearGradientBrush.GradientStops>
                            <GradientStop Color="Gray" Offset="0" />
                            <GradientStop Color="#eeeeee" Offset="1" />
                        </LinearGradientBrush.GradientStops>
                    </LinearGradientBrush>
                </Border.BorderBrush>
            <StackPanel Name="EmbedForm" Height="100" Width="400" ></StackPanel>
        </Border>

            <Rectangle Grid.Row="1" VerticalAlignment="Top"
               Width="{Binding ElementName=inkBorder,Path=ActualWidth}"
               Height="{Binding ElementName=inkBorder,Path=ActualHeight}">

                <Rectangle.OpacityMask>
                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                        <LinearGradientBrush.GradientStops>
                            <GradientStop Offset="0.0" Color="#66000000" />
                            <GradientStop Offset="1.0" Color="#00000000" />
                        </LinearGradientBrush.GradientStops>
                    </LinearGradientBrush>
                </Rectangle.OpacityMask>
                <Rectangle.Fill>
                    <VisualBrush 
          Visual="{Binding ElementName=inkBorder}">
                        <VisualBrush.RelativeTransform>
                            <TransformGroup>
                                <ScaleTransform ScaleX="1" ScaleY="-1" />
                                <TranslateTransform Y="1" />
                            </TransformGroup>
                        </VisualBrush.RelativeTransform>
                    </VisualBrush>
                </Rectangle.Fill>
            </Rectangle>
        </Grid>

To clarify the question a bit...

I am mainly looking for a way to apply any visual transformations to controls like the WindowsFormHost and the WebBrowser control. I've found that even simple transformations do not work with these, and I was wondering if there is any trick to treating these like standard visual elements or if it is a lost cause.

+2  A: 

Transformations on WindowsFormsHost or WebBrowser won't work, because these controls don't use the WPF rendering engine, they use GDI+.

As far as I know, the only way to achieve what you want would be to capture the control's content as an image, and manually perform the transformation on the image using GDI+ functions... It's quite easy for a simple reflection, but it can get tricky for other kinds of transformation...

Thomas Levesque
Thank you - This is exactly what I needed to know - If I may ask though do you by any chance have a link to resources on capturing the image ? My searches are being very unproductive. Thank you very much for the help.
apocalypse9
Have a look at this link : http://www.developerfusion.com/code/4630/capture-a-screen-shot/. It should work for a control as well (since a Win32 control has a window handle)
Thomas Levesque
Thank you very much! Sorry to add to the question like that.
apocalypse9