2014-02-16 32 views
0

我已经添加了一个图像到我的布局,包含在一个视图框中,但是当我运行该应用程序时,图像KinectVideo不显示在屏幕上。如何在包含在ViewBox中时使图像可见?

是否有我在布局中丢失的属性orshould我重新排列了布局中的图像以使其再次可见?

这是我如何定义的布局:

<Window x:Class="BVversion1.ConditioningFrm" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="ConStackPanelditioningFrm" Height="377.612" Width="637.313"> 
    <Viewbox Stretch="Uniform" HorizontalAlignment="Center"> 
     <StackPanel Orientation="Vertical"> 
      <StackPanel Orientation="Horizontal"> 
      <Button x:Name="pushUpBtn" Content="Push Ups" Width="100" Click="pushUpBtn_Click"/> 
      <Button x:Name="burpeeBtn" Content="Burpee" Width="100" Click="burpeeBtn_Click"/> 
      <Button x:Name="squatBtn" Content="Squat" Width="100" Click="squatBtn_Click"/> 
      <Button x:Name="coreBtn" Content="Core" Width="100" Click="coreBtn_Click"/>  
      </StackPanel> 
      <Image x:Name="KinectVideo" Width="640" Height="250" Visibility="Visible"/> 
      <Button x:Name="homeBtn" Content="Home" Width="75" Click="homeBtn_Click"/> 
     </StackPanel> 
    </Viewbox> 
</Window> 

设置图像源位图:

KinectVideo.Source = BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96, 
        PixelFormats.Bgr32, null, colorData, colorFrame.Width * colorFrame.BytesPerPixel) 
+0

你在哪里设置了Image的'Source'? –

+0

@Rohit我添加了详细的问题,显示我如何添加source.This代码工作时,图像只是在viewbox中的元素,但是当我添加按钮和stackpanel它不。 –

回答