Reputation: 77
I get an error when trying to run this code. The error is
the property 'content' is more than once
The problem occurred when I included `
Border BorderBrush="Transparent" BorderThickness="1" CornerRadius="15">
</Border>
Here is the full code:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPF_test"
xmlns:Properties="clr-namespace:WPF_test.Properties" x:Class="WPF_test.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="248" AllowsTransparency="True" Width="459" WindowStyle="None" WindowStartupLocation="CenterScreen">
<Window.Background>
<ImageBrush ImageSource="Images/BlueBackground.jpg"/>
</Window.Background>
<Border BorderBrush="Transparent" BorderThickness="1" CornerRadius="15">
</Border>
<Grid Margin="0,0,2,2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="101*"/>
<ColumnDefinition Width="348*"/>
</Grid.ColumnDefinitions>
<Label x:Name="label" Foreground="White" Content="Login" HorizontalAlignment="Left" Margin="118,0,0,0" VerticalAlignment="Top" Height="51" Width="120" FontSize="36" FontFamily="Consolas" Grid.Column="1"/>
<Label x:Name="label1" Foreground="White" Content="User Name" HorizontalAlignment="Left" Margin="105,79,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.474,1.808" FontSize="16" FontFamily="Consolas" Grid.Column="1" Height="29" Width="89"/>
<Label x:Name="label2" Foreground="White" Content="Password" HorizontalAlignment="Left" Margin="105,123,0,0" VerticalAlignment="Top" FontSize="16" FontFamily="Consolas" Grid.Column="1" Height="29" Width="80"/>
<TextBox x:Name="textBox" HorizontalAlignment="Left" Height="23" Margin="209,129,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120" Grid.Column="1"/>
<TextBox x:Name="textBox1" HorizontalAlignment="Left" Height="0" Margin="147,129,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="3" Grid.Column="1"/>
<TextBox x:Name="textBox2" HorizontalAlignment="Left" Height="23" Margin="209,82,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120" Grid.Column="1"/>
<Button x:Name="button" Content="Login" HorizontalAlignment="Left" Margin="105,180.525,0,0" VerticalAlignment="Top" Width="89" Height="27" FontFamily="Consolas" UseLayoutRounding="False" Grid.Column="1"/>
<Button x:Name="button1" Content="Cancel" HorizontalAlignment="Left" Margin="240,181,0,0" VerticalAlignment="Top" Width="89" Height="27" FontFamily="Consolas" Grid.Column="1"/>
</Grid>
</Window>
Can anyone help me figure out what the problem is Thank you
Upvotes: 0
Views: 89
Reputation: 2457
The issue is that a Window
can only have one content property set and you added a Grid
alongside a Border
. Instead try:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPF_test"
xmlns:Properties="clr-namespace:WPF_test.Properties" x:Class="WPF_test.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="248" AllowsTransparency="True" Width="459" WindowStyle="None" WindowStartupLocation="CenterScreen">
<Window.Background>
<ImageBrush ImageSource="Images/BlueBackground.jpg"/>
</Window.Background>
<Border BorderBrush="Transparent" BorderThickness="1" CornerRadius="15">
<Grid Margin="0,0,2,2">
....
</Grid>
</Border>
</Window>
This way, the Border
is the content property of the Window
and the Grid
is the Child
element of the Border
.
Upvotes: 6