1

画像のサムネイルを表示するリスト ボックスを含むエキスパンダーがあります。リストボックスのサイズに応じて画像のサイズを変更し、エキスパンダーの幅に基づいてリストボックスのサイズを変更したい。エキスパンダーを展開すると、リスト ボックスと画像のサイズも変更されます。これを達成する方法を知っている人はいますか?

   <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>
4

1 に答える 1

1

画像の「ストレッチ」プロパティを使用して:

<Image 
     Source="{Binding FileLocation}"
     Margin="0,5"
     MouseLeftButtonDown="DragImage"
     Stretch="Uniform"
     StretchDirection="Both"/>

値を操作して、必要な効果を得ることができます。

http://msdn.microsoft.com/en-en/library/system.windows.controls.image.stretch.aspx

http://msdn.microsoft.com/en-en/library/system.windows.controls.image.stretchdirection.aspx

http://msdn.microsoft.com/en-us/library/system.windows.media.stretch.aspx

http://msdn.microsoft.com/en-us/library/system.windows.controls.stretchdirection.aspx

于 2010-12-22T10:45:18.787 に答える