【问题标题】:Replace the contents of a WPF grid after a button click单击按钮后替换 WPF 网格的内容
【发布时间】:2014-11-27 13:10:33
【问题描述】:

我正在尝试修改 C# Kinect 示例(Kinect Fusion Explorer)。

在应用程序的主窗口中,有一个显示 kinect fusion feed 的 3D 渲染的网格。

我想知道是否可以在单击表单中的按钮后替换此网格的内容。

<Grid x:Name="CompositeHost" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" HorizontalAlignment="Left" ClipToBounds="False" >
    <Viewbox Grid.Column="0">
        <Image Name="shadedSurfaceImage"/>
    </Viewbox>
    <Viewport3D Name="GraphicsViewport" IsHitTestVisible="False" >
        <!-- 3D elements are added here programatically, for performance can add the following to line above: RenderOptions.EdgeMode="Aliased"  -->
    </Viewport3D>
</Grid>

现在提要使用 ViewPort3D 来输出提要。我想在单击按钮后输出一个简单的视频源。以下是简单视频源的 XAML 外观:

<Grid>
    <Image Name="videoImage"/>
</Grid>

我对 C# 和 WPF 开发完全陌生,所以我只想知道这是否可以实现,或者我是否必须打开一个全新的窗口来显示视频源。

谢谢

【问题讨论】:

    标签: c# wpf xaml kinect


    【解决方案1】:

    我正在做一个实际使用很多的项目,我需要在不同的网格之间导航。我正在使用单个窗口和不同的页面,这是我正在做的一个很好的例子: http://www.dotnetfunda.com/articles/show/2214/how-to-do-push-to-press-with-kinect-sdk-17 那个不是我做的项目,但基本上是这样的:

    <DockPanel>
            <Frame x:Name="_mainFrame"    NavigationUIVisibility="Hidden" />
    </DockPanel>
    

    在这一部分中,您声明了 mainFrame,它是将在 windows 上更改的内容。

    (Application.Current.MainWindow.FindName("_mainFrame") as Frame).Source = new Uri("theOtherPage.xaml", UriKind.Relative);
    

    这里是点击事件。

    记住使用 Uri 类加载不同的资源并命名您要更改的大型机。

    【讨论】:

    • 请在您的答案中提供链接的本质。仅链接问题不被认为是可接受的。
    猜你喜欢
    • 2015-01-21
    • 1970-01-01
    • 1970-01-01
    • 2016-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-19
    • 1970-01-01
    相关资源
    最近更新 更多