我试图为我的数据模板控件设置宽度和高度属性,但我的控件保持其默认大小。
<ItemsControl Grid.Row="1" x:Name="containerUsers" ItemsSource="{Binding ValidUsers}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" AllowDrop="True" ClipToBounds="False" DragEnter="panelUsers_DragEnter" Drop="panelUsers_Drop" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<my:PictureLabelControl Width="20" Height="50" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
事实上,我有三个这样的面板,我希望当涉及到另一个面板时,我可以通过拖放来更改控件的大小。
<UserControl x:Class="VHTService.Wfm.View.PictureLabelControl"
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"
mc:Ignorable="d" Cursor="Hand" Focusable="True" Margin="3">
<Grid>
<Grid Name="grid1">
<Label Content="{Binding LabelText}" Focusable="True" FontSize="12" FontWeight="Normal" HorizontalContentAlignment="Center"
Name="lblPicture" VerticalContentAlignment="Center" Height="26" VerticalAlignment="Bottom" />
<Image Source="{Binding Picture}" Focusable="True" Name="imgAvatar" Stretch="Uniform" Margin="0,0,0,26" GotFocus="imgAvatar_GotFocus"
LostFocus="imgAvatar_LostFocus" />
</Grid>
</Grid>