Visual Studio 2012 XAML 设计器 - 不能添加多个项目 [英] Visual Studio 2012 XAML Designer - Cannot add more than one item

查看:26
本文介绍了Visual Studio 2012 XAML 设计器 - 不能添加多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 VS 2012 的新手,每次使用 XAML 设计器时都会遇到这个问题.

I'm new to VS 2012, and I have this issue every time I use the XAML Designer.

每次我向窗口添加一个项目(例如 RadioButton、图像、标签)时,它都会删除前一个.

Every time I add an item (e.g. a RadioButton, and Image, a Label) to my window, it deletes the previous one.

结果,我的窗口中只能有一个项目,我知道这很荒谬,我错过了什么?

As a result, I can have only one item in my window, I know it is absurd, what am I missing?

这是窗口的xaml

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:WpfViewers="clr-namespace:Microsoft.Samples.Kinect.WpfViewers;assembly=Microsoft.Samples.Kinect.WpfViewers" xmlns:Toolkit="clr-namespace:Microsoft.Kinect.Toolkit;assembly=Microsoft.Kinect.Toolkit" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="KinectSetupDev.MainWindow"
    Title="MainWindow" Height="400" Width="600">
    <Toolkit:KinectSensorChooserUI x:Name="SensorChooserUI" VerticalAlignment="Center" Height="40" Margin="277,2,275,328"/>
</Window>

这是拖动图像后窗口的xaml(来自工具箱)

Here is the xaml of the window after dragging an image on it (from the Toolbox)

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:WpfViewers="clr-namespace:Microsoft.Samples.Kinect.WpfViewers;assembly=Microsoft.Samples.Kinect.WpfViewers" xmlns:Toolkit="clr-namespace:Microsoft.Kinect.Toolkit;assembly=Microsoft.Kinect.Toolkit" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="KinectSetupDev.MainWindow"
    Title="MainWindow" Height="400" Width="600">
<Image HorizontalAlignment="Left" Height="86" Margin="77,188,0,0" VerticalAlignment="Top" Width="111"/>
</Window>

推荐答案

正如@Hans 所明确指出的,我试图在 XAML 设计器中将多个内容项添加到一个窗口中.这是不可能的,所以我不得不:

As made clear by @Hans, I was trying to add multiple content items into a Window, in the XAML designer. This is just not possible so i had to:

1) 向窗口添加网格.

1) Add a Grid to the Window.

2) 将任何项目添加到网格中.

2) Add any item to the grid.

它有效,这是一个示例代码:

It works, here is a sample code:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:WpfViewers="clr-namespace:Microsoft.Samples.Kinect.WpfViewers;assembly=Microsoft.Samples.Kinect.WpfViewers" xmlns:Toolkit="clr-namespace:Microsoft.Kinect.Toolkit;assembly=Microsoft.Kinect.Toolkit" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="KinectSetupDev.MainWindow"
    Title="MainWindow" Height="768" Width="1024" Loaded="Window_Loaded_1">
    <Grid HorizontalAlignment="Left" Height="736" VerticalAlignment="Top" Width="1012" Margin="2,2,0,0">
       <Image x:Name="Image01" HorizontalAlignment="Left" Height="240" Margin="136,27,0,0" VerticalAlignment="Top" Width="320"/>
       <TextBlock x:Name="tbMessages" HorizontalAlignment="Left" Height="60" Margin="10,606,-664,-426" TextWrapping="Wrap" VerticalAlignment="Top" Width="974"/>
       <WpfViewers:KinectColorViewer HorizontalAlignment="Left" Height="240" Margin="666,0,-666,0" VerticalAlignment="Top" Width="320"/>
    </Grid>
</Window>

这篇关于Visual Studio 2012 XAML 设计器 - 不能添加多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆