0

ウィンドウのサムネイルを表示するためのユーザーコントロールがあります

ユーザー コントロール XAML :

<Grid x:Name="containerGrid" Margin="0">
        <Border Background="White" CornerRadius="5">
            <Border.Style>
                <Style>
                    <Style.Triggers>
                        <Trigger Property="Border.IsMouseOver" Value="True">
                            <Setter Property="Border.Effect">
                                <Setter.Value>
                                    <DropShadowEffect BlurRadius="20" Color="White" ShadowDepth="0" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
            <Border x:Name="containerBorder" CornerRadius="5" BorderThickness="1" BorderBrush="Black">
                <Border.Background>
                    <VisualBrush x:Name="vb" />
                </Border.Background>                
            </Border>
        </Border>
    </Grid>

新しいウィンドウが作成されたら、上記のユーザー コントロールに VisualBrush によるウィンドウ コンテンツのサムネイルを表示させます。

vb.Visual = (Border)Win.Template.FindName("mainBorder", Win);

すべてがうまくいくようです...

開かれた窓 ここに画像の説明を入力

サムネイル

ここに画像の説明を入力

ユーザーがウィンドウサイズを変更するまで... ここに画像の説明を入力

サムネイル

ここに画像の説明を入力

私の質問は、ソース (ウィンドウ) のサイズがどのように変化しても、サムネイルの幅と高さを常にユーザー コントロール (200 X 200) に合わせるにはどうすればよいですか??

手がかりがあればよろしくお願いします。

Stretch を Fill に、ViewBox をウィンドウの ActualWidth と ActualHeight に設定することで解決

<VisualBrush x:Name="vb" Stretch="Fill" ViewboxUnits="Absolute">
                        <VisualBrush.Viewbox>
                            <MultiBinding Converter="{CONV:WidthHeightToRectConverter}">
                                <Binding Path="Win.ActualWidth" />
                                <Binding Path="Win.ActualHeight" />
                            </MultiBinding>
                        </VisualBrush.Viewbox>                        
                    </VisualBrush>
4

1 に答える 1