【发布时间】:2016-10-16 17:36:35
【问题描述】:
我正在尝试在 UniformGrid 的基础上制作用户控件。使用office时出现错误:属性'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>
...
【问题讨论】:
-
当你想“在UniformGrid的基础上做用户控件”并想给它添加子元素时,你应该解释为什么你不能直接使用UniformGrid(而不是你的控件) .你到底想达到什么目的?
-
To 元素是浮动的,并且在您更改内容宽度时同时被拉伸。 s3.postimg.org/wc2dqkayb/323.png
-
你应该创建一个custom panel。
标签: c# wpf xaml uniformgrid