有谁知道是否可以在 WPF Wrap 面板中输入换行符?它违背了包裹面板的用途,所以我不确定是否可能。
如果不是,是否有任何其他 WPF 控件实际上允许我在其中输入换行符并支持添加子项(我自己的自定义控件?)
最佳答案
public class NewLine : FrameworkElement
{
public NewLine()
{
Height = 0;
var binding = new Binding
{
RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(WrapPanel), 1),
Path = new PropertyPath("ActualWidth")
};
BindingOperations.SetBinding(this, WidthProperty, binding);
}
}
<WrapPanel>
<TextBox Text="Text1"/>
<TextBox Text="Text2"/>
<my:NewLine/>
<TextBox Text="Text3"/>
<TextBox Text="Text4"/>
</WrapPanel>
关于wpf - 向 WPF 换行面板添加换行符/换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3587092/