0
テンプレートから値を変更します。WPF:私はXAMLで、次の「スタイル」を作成しました
<Style TargetType="Button" x:Key="iconButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Margin="5">
<Ellipse Width="45" Height="45" Fill="White" Opacity="0"/>
<TextBlock Foreground="White"
HorizontalAlignment="Center"
VerticalAlignment="Center">hello</TextBlock>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<!--TODO - change the "opacity" of the ellipse.
Maybe binding is necessary? -->
</Trigger>
</Style.Triggers>
</Style>
は私が(スタイルのテンプレート内にある)楕円の「不透明度」プロパティを変更したいですマウスでボタンを覆っています。
これはどのように達成できますか?
「バインディング」や「ダイナミックソース」を使用する必要がありますか?もしそうなら、どう?
またのControlTemplateでTextBlock内のボタンのコンテンツを表示することもできます。 ' '。それとも、TextBlockをContentPresenterで置き換えてください。 –
Clemens