Visual Studio 2012 XAML Designer - Cannot Add Multiple Elements

I am new to VS 2012 and I have this problem every time I use the XAML constructor.

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

As a result, I can only have one element in my window, I know that this is absurd, what am I missing?

Here is the xaml window

<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> 

Here is the xaml window after dragging the image onto it (from the toolbar)

 <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> 
+4
source share
1 answer

As @Hans explained, I tried to add several content elements to the Window, in the XAML design. This is simply not possible, so I had to:

1) Add a grid to the window.

2) Add any element to the grid.

This 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> 
+4
source

Source: https://habr.com/ru/post/1444089/


All Articles