在UserControl WPF中的Viewport中使用VisualBrush

时间:2014-06-28 04:18:20

标签: c# wpf

我试图在UserControl中的Viewport3D中使用VisualBrush,当我在Blend for Visual Studio环境中时,一切都很好,它显示了!但是当我调试项目时它根本就不会出现!

我在UserControl中有2个网格(作为页面)和1个Viewport3D对象,我希望当我单击“前进”按钮时,Viewport3D将page1翻转到page2,它在Window中工作正常,但我无法使用它在UserControl中,我的意思是它不会出现。

如果可以,请指导我。

UserControl.cs链接 - > Click Here

1 个答案:

答案 0 :(得分:0)

如果您只是期待将视觉画笔视为漫反射材料

你去吧

<Grid>
    <Grid x:Name="Page1_Grid" HorizontalAlignment="Left" Height="210" VerticalAlignment="Top" Width="216" Visibility="Hidden">
        <Grid x:Name="Page1" HorizontalAlignment="Left" Height="210" VerticalAlignment="Top" Width="216">
            <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="190" VerticalAlignment="Top" Width="196" Margin="10,10,0,0" CornerRadius="5" Background="#FFFF9B9B" RenderTransformOrigin="-0.041,0.411">
                <Button x:Name="button" Content="Forward" Margin="9,19,99,130" Click="Button_Click"/>
            </Border>
        </Grid>
    </Grid>
    <Grid x:Name="Page2_Grid" HorizontalAlignment="Left" Height="210" VerticalAlignment="Top" Width="216" Visibility="Hidden" d:IsHidden="True">
        <Grid x:Name="Page2" HorizontalAlignment="Left" Height="210" VerticalAlignment="Top" Width="216">
            <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="190" VerticalAlignment="Top" Width="196" Margin="10,10,0,0" CornerRadius="5" Background="#FFFF9B9B" RenderTransformOrigin="-0.041,0.411">
                <Button Content="Back" Margin="9,19,99,130"/>
            </Border>
        </Grid>
    </Grid>
    <Viewport3D HorizontalAlignment="Left" Height="190" VerticalAlignment="Top" Width="196" Margin="10,10,0,0">
        <Viewport3D.Camera>

我在视口之前移动了包含画笔视觉效果的网格,以便在漫反射材质可以拾取之前准备就绪。