2014-02-16 20 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它不。 –

回答