多田!
我现在已经制作了一个有效的测试用例,如果我有一个代码,stackpanel 会变得很好。要处理的属性需要 InitializeComponent。
MainWindow.xaml:
<Window x:Class="wpftestapp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:v="clr-namespace:wpftestapp.views"
Title="MainWindow" Height="350" Width="525">
<v:HPanel>
<Label Content="a"/>
<Label Content="b"/>
<Label Content="c"/>
</v:HPanel>
</Window>
HPanel.xaml:
<StackPanel Orientation="Horizontal"
x:Class="wpftestapp.views.HPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"/>
HPanel.xaml.cs:
using System.Windows.Controls;
namespace wpftestapp.views
{
public partial class HPanel : StackPanel
{
public HPanel()
{
InitializeComponent();
}
}
}
谢谢您的帮助!