我遇到Button
控制问题。我在Button
圈内Shape
和MediaElement
圈内<Application.Resources>
<ControlTemplate x:Key="Templ" TargetType="{x:Type Button}">
<Grid Margin="5">
<Ellipse Fill="#FF6DB4EF"/>
<Ellipse Width="100" Height="100">
<Ellipse.Fill>
<RadialGradientBrush>
<GradientStop Offset="0" Color="#00000000"/>
<GradientStop Offset="0.88" Color="#00000000"/>
<GradientStop Offset="1" Color="#80000000"/>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse Margin="10">
<Ellipse.Fill>
<VisualBrush>
<VisualBrush.Visual>
<MediaElement Source="{???}" Stretch="Fill"/>
</VisualBrush.Visual>
</VisualBrush>
</Ellipse.Fill>
</Ellipse>
</Grid>
</ControlTemplate>
</Application.Resources>
。那是我的代码:
MediaElement
我的问题是我无法绑定来自主XAML
的{{1}}来源:
<Button Template="{DynamicResource Templ}" Content="D:\dykta.avi"/>
有没有办法让它发挥作用?
答案 0 :(得分:1)
如果要从按钮的MediaElement.Source
属性获取Content
属性,只需绑定到它:
<MediaElement Source="{Binding Path=Content, RelativeSource={RelativeSource AncestorType=Button}}"
Stretch="Fill"/>