2011-01-11 12 views
1

こんにちは 画像でRadialButtonスタイルを作成しようとしていますが、その画像(ソース)を可変にします。wpfスタイル楕円ボタン塗りつぶしプロパティ画像

<Style x:Key="RadialButton1" TargetType="Button"> 
       <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="Button"> 
         <Ellipse 
          Stroke="Black" 
          HorizontalAlignment="Center" 
          VerticalAlignment="Center" 
          Width="60" 
          Height="60" 
          x:Name="Ellipse" > 
          <Ellipse.Fill > 
           <ImageBrush ImageSource="/DessCol;component/Images/Recommencer.ico"/> 
          </Ellipse.Fill> 
         </Ellipse> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 

....

<Button Height="37" HorizontalAlignment="Left" Margin="15,20,0,0" Name="btnRecommencer" VerticalAlignment="Top" Width="51" Style="{StaticResource RadialButton1}" Click="btnRecommencer_Click"/> 

私はEllipse.Fillプロパティは変数やボタンのコンテンツ属性によって設定されたことにしたいです。 私はバインディング、RelativeSourceなどに見ることになります...誰かがこの

補遺

<Ellipse Fill="{TemplateBinding Content}"/> 
よう

何かをありがとう達成する方法のアイデアを持っている場合いただければ幸いです

答えて

2

バインディングでRelativeSourceを使用できます

<Style x:Key="RadialButton1" TargetType="Button"> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="Button"> 
       <Ellipse Stroke="Black" HorizontalAlignment="Center" VerticalAlignment="Center" 
         Width="60" Height="60" x:Name="Ellipse" > 
        <Ellipse.Fill > 
         <ImageBrush ImageSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}}, 
                  Path=Content}"/> 
        </Ellipse.Fill> 
       </Ellipse> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 
+0

b楕円内のクリックイベントに応答しました – Nestor

+0

申し訳ありませんが、あなたは正しいです。ボタンの高さ= "37" Horizo​​ntalAlignment = "Left" Margin = "100,20,0,0" Name = "btnToutDessiner" Style = "{StaticResource RadialButton2}" VerticalAlignment = "Top" Width = "51" Click = "btnToutDessiner_Click" Content = "/ DessCol; component/Images/ToutDessiner.ico"> – Nestor

+0

@Nestor:あなたの問題を解決した場合、 –

関連する問題