流布局WPF 3.5 [英] Flow Layout WPF 3.5
本文介绍了流布局WPF 3.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一些标签和文本框,但是,如果我折叠一个标签和文本框,则下面的其他标签和文本框会上升.在WPF 3.5中有办法做到这一点吗?
我正在使用这个:
Hi,
I want to create some labels and textbox but, if I collapse one then the others below will go up. There is a way to do this in WPF 3.5?
I am using this:
<<pre lang="xml">Window x:Class="FlowLayoutTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="Window1" Height="300" Width="418" WindowStartupLocation="CenterScreen">
<Grid ShowGridLines="False">
<WindowsFormsHost Margin="0,37,0,104" x:Name="WindowsFormsHost">
<wf:FlowLayoutPanel x:Name="flowLayoutPanel1" >
</wf:FlowLayoutPanel>
</WindowsFormsHost>
<Button Height="23" Margin="0,37,0,0" Name="button1" VerticalAlignment="Top" HorizontalAlignment="Left" Width="75" Click="button1_Click">Button</Button>
</Grid><
但是int我运行应用程序时wpf表单没有显示任何内容...
but int the wpf form is not showing anything when I run the application...
推荐答案
使用 StackPanel 控件作为您的Layout控件
示例:
Use StackPanel control as your Layout control
Example:
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Name:" VerticalAlignment="Center"/>
<TextBox Width="200"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Age:" VerticalAlignment="Center"/>
<TextBox Width="200"/>
</StackPanel>
</StackPanel>
</Window>
这篇关于流布局WPF 3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文