0

Expression Design で作成した画像を Blend にインポートしてボタンを作成しようとしています。Blendでサイズを変更するときに、ボタンのサイズをコンテナ(おそらくグリッド)で拡大しようとしています。残念ながら、両方の製品のドキュメントはあまり役に立ちません。デザインの xaml は次のようになります。

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="Document" Width="61" Height="61" Clip="F1 M 0,0L 61,0L 61,61L 0,61L 0,0">
<Canvas x:Name="MinimizeButtonBase" Width="799.999" Height="600" Canvas.Left="0" Canvas.Top="0">
    <Viewbox x:Name="Group" Width="61" Height="61" Canvas.Left="0" Canvas.Top="0">
        <Canvas Width="61" Height="61">
            <Path x:Name="Path" Width="61" Height="61" Canvas.Left="0" Canvas.Top="3.05176e-005" Stretch="Fill" StrokeLineJoin="Round" Stroke="#B0000000" Data="F1 M 5.5,0.500031L 55.5,0.500031C 58.2614,0.500031 60.5,2.73859 60.5,5.5L 60.5,55.5C 60.5,58.2614 58.2614,60.5 55.5,60.5L 5.5,60.5C 2.73859,60.5 0.5,58.2614 0.5,55.5L 0.5,5.5C 0.5,2.73859 2.73859,0.500031 5.5,0.500031 Z ">
                <Path.Fill>
                    <LinearGradientBrush StartPoint="0.561118,0.955553" EndPoint="0.58334,-0.177781">
                        <LinearGradientBrush.GradientStops>
                            <GradientStop Color="#B0000000" Offset="0"/>
                            <GradientStop Color="#B0FFFFFF" Offset="1"/>
                        </LinearGradientBrush.GradientStops>
                    </LinearGradientBrush>
                </Path.Fill>
            </Path>
            <Path x:Name="Line" Width="49.2547" Height="5" Canvas.Left="5.23578" Canvas.Top="47" Stretch="Fill" StrokeThickness="5" StrokeLineJoin="Round" Stroke="#B0000000" Data="M 7.73578,49.5L 51.9904,49.5"/>
        </Canvas>
    </Viewbox>
</Canvas>

シンプルな 2 パス画像をデザインにインポートしてブレンドのボタンにする手順を知っている人はいますか? 次の xaml をブレンドのリソース ファイルに追加すると、コントロールに変換した後にサイズを変更するときに、ボタンをコンテナーに合わせてスケーリングできません。

4

2 に答える 2

0

スケーラブルにする最も簡単なレイアウト コンテナーは ViewBox です。これは WPF の標準コントロールであり、Silverlight では (私が思うに) SL ツールボックスにあります。

于 2009-11-27T20:51:49.147 に答える
0

問題は、使用したコンテナーの種類とそれが生成した XAML の複雑さです。キャンバスは絶対的な配置であり、実際にはスケーリングに使用するべきではありません。これを回避するには、スケールを模倣するビュー ボックスを用意しますが、これは必須ではありません。

Expression 3 でプロジェクトを開始し、ユーザー コントロールを追加し、そこにコードを貼り付けて作業しました。ボタンのベースに対する下部の水平パスの位置は明確ではありませんでした。その位置と幅を変更し、グリッド列の高さと幅の値を適切に変更し、それらを絶対数ではなく比率として維持する必要がある場合.

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    x:Class="WpfApplication1.UserControl1"
    x:Name="UserControl">

    <Grid x:Name="Document">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="1*"/>
             <ColumnDefinition Width="8*"/>
             <ColumnDefinition Width="1*"/>
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
             <RowDefinition Height="8*"/>
             <RowDefinition Height="1*"/>
             <RowDefinition Height="1*"/>
         </Grid.RowDefinitions>
         <Path Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="3"
               x:Name="Path" 
               Stretch="Fill" StrokeLineJoin="Round" Stroke="#B0000000" 
               Data="F1 M 5.5,0.500031L 55.5,0.500031C 58.2614,0.500031 60.5,2.73859 60.5,5.5L 60.5,55.5C 60.5,58.2614 58.2614,60.5 55.5,60.5L 5.5,60.5C 2.73859,60.5 0.5,58.2614 0.5,55.5L 0.5,5.5C 0.5,2.73859 2.73859,0.500031 5.5,0.500031 Z "> 
             <Path.Fill>                           
                 <LinearGradientBrush StartPoint="0.561118,0.955553" EndPoint="0.58334,-0.177781">         
                     <LinearGradientBrush.GradientStops> 
                         <GradientStop Color="#B0000000" Offset="0"/>                        
                         <GradientStop Color="#B0FFFFFF" Offset="1"/>     
                     </LinearGradientBrush.GradientStops> 
                 </LinearGradientBrush>                    
            </Path.Fill>                     
       </Path>     
       <Path x:Name="Line" Stretch="Fill"
             StrokeThickness="5" StrokeLineJoin="Round" Stroke="#B0000000" 
             Data="M 7.73578,49.5L 51.9904,49.5" 
             Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" />
    </Grid>
</UserControl>

適切なコントロールになる場合は、何らかの形でコンテンツ プレゼンテーションの追加を開始する必要がありますが、これでサイズ変更の問題は解決するはずです。

編集 : 設定した追加の配置とマージンは不要になったため、削除しました。

于 2009-11-22T01:43:20.830 に答える