后台获取button中这个Image的Source属性 WPF的技术
ButtonHorizontalAlignment="Left"Margin="871,11,0,0"Name="button1"VerticalAlignment="T...
Button HorizontalAlignment="Left" Margin="871,11,0,0" Name="button1" VerticalAlignment="Top" BorderThickness="0" Cursor="Hand" Visibility="Visible" Click="button1_Click">
<Button.Style>
<Style TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Image Name="coles" Stretch="None" Source="/FiscalEncyclopedia;component/Images/close_03.png"></Image>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button
我想后台获取button中这个Image的Source属性 展开
<Button.Style>
<Style TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Image Name="coles" Stretch="None" Source="/FiscalEncyclopedia;component/Images/close_03.png"></Image>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button
我想后台获取button中这个Image的Source属性 展开
展开全部
var s = this.button1.Style.Setters[0] as Setter;
var t = s.Value as ControlTemplate;
var g = t.LoadContent() as Grid;
var b = g.Children[0] as Image;
var source = b.Source;
最后的source 就是你要的值。
var t = s.Value as ControlTemplate;
var g = t.LoadContent() as Grid;
var b = g.Children[0] as Image;
var source = b.Source;
最后的source 就是你要的值。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询