Search code examples
c#wpfxamluniformgrid

C# WPF UserControl based on Uniformgrid


I'm trying to make the user control on the basis of UniformGrid. When using office error appears: The property 'Content' is set more than once

AdaptiveLayout.xaml

<UserControl x:Class="App.Controls.AdaptiveLayout"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:element="clr-namespace:App.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UniformGrid SizeChanged="UniformGrid_SizeChanged">
        <ContentPresenter></ContentPresenter>
    </UniformGrid>

</UserControl>

MainWindow.xaml

...
<controls:AdaptiveLayout TransferringAfter="190">
         <controls:TextBoxWrapControl LabelContent="FirstName"></controls:TextBoxWrapControl>
         <controls:TextBoxWrapControl LabelContent="LastName"></controls:TextBoxWrapControl>
 </controls:AdaptiveLayout>
...

Solution

  • You are using a UniformGrid in your UserControl, but that does not actually make it into one. That's why it's complaining in your MainWindow.xaml that you set more than one content for your AdaptiveLayout. You could try extending UniformGrid instead of using it.