分析WPF的一段xaml代码:
1 <UserControl x:Class="UserControl1" 2 xmlns="..." 3 xmlns:x="..." 4 xmlns:mc="..." 5 xmlns:d="..." 6 xmlns:local="clr-namespace:WpfApp3" 7 mc:Ignorable="d" 8 d:DesignHeight="450" d:DesignWidth="800"> 9 <Grid> 10 <Border BorderBrush="Blue" BorderThickness="2" Margin="5,3"> 11 <ListBox ItemsSource="{Binding Datas}" SelectedItem="{Binding SelectedData}"> 12 <ListBox.ItemTemplate> 13 <DataTemplate> 14 <Border Background="LightGreen" BorderBrush="LightYellow" BorderThickness="1" Margin="1"> 15 <StackPanel Orientation="Horizontal"> 16 <TextBlock Width="100" Text="{Binding Name}" /> 17 <TextBlock Margin="10,0,0,0" Text="{Binding Age}" Width="100"/> 18 </StackPanel> 19 </Border> 20 </DataTemplate> 21 </ListBox.ItemTemplate> 22 </ListBox> 23 </Border> 24 </Grid> 25 </UserControl>
代码 |
解释 |
xmlns:local="clr-namespace:WpfApp3" |
包名 |
DesignHeight="450" |
窗体的高 |
DesignWidth="800" |
窗体的宽 |
BorderBrush="Blue" | 外部边框颜色 |
BorderThickness="2" | 边框厚度 |
Margin="1" |
四个边距都是 1px |
Margin="5,3" |
上边距和下边距是 5px 右边距和左边距是 3px |
margin:10px 5px 15px; |
|
ListBox ItemsSource="{Binding Datas}" | |
ListBox SelectedItem="{Binding SelectedData}" | |
<ListBox.ItemTemplate> | |
<DataTemplate> |
原文地址:https://www.cnblogs.com/qq2806933146xiaobai/p/12342070.html
时间: 2024-10-14 05:53:47