开发者

Creating a reflection of a WindowsFormHost in wpf

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>
                            <Gradie开发者_StackOverflow社区ntStop 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.


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜