我有一个带有列表框的扩展器,其中显示图像缩略图。我希望根据列表框的大小调整图像的大小,并根据扩展器的宽度调整列表框的大小。当我展开扩展器时,我希望列表框和图像也可以调整大小。有谁知道我怎么能做到这一点?
<Expander
Style="{DynamicResource ExpanderStyle}"
Name="pictureExpander"
IsExpanded="True"
ExpandDirection="Left"
Collapsed="pictureExpander_Collapsed"
Expanded="pictureExpander_Expanded"
Grid.Column="4">
<ListBox
Name="photoList"
ItemsSource="{Binding Source={StaticResource PhotoBin}}"
IsSynchronizedWithCurrentItem="True"
HorizontalAlignment="Stretch"
ScrollViewer.CanContentScroll="False">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Yellow" />
</Style.Resources>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="5"/>
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<Image
Source="{Binding FileLocation}"
Margin="0,5"
HorizontalAlignment="Stretch"
MouseLeftButtonDown="DragImage" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Expander>