wpf按钮样式加图片

wpf按钮样式加图片,第1张

1.图片问题,你可以做几个style继承那个style(Base on)就可以解决了。如: <Style x:key="button_style1" BasedOn="{StaticResource yourBaseStyle}" TargetType="{x:Type Button}"><Style.Setters><Setter Property="Background" Value="Image path1"/></Style.Setters></Style>然后在你的button中中指定这个style,如:<Button x:Name="button1" Style="{DynamicResource button_style1}" Content="Test"/>2. 你的资源文件保存成图片也不会难和发时间吧?如确要这么做,请参考 http://wenwen.soso.com/z/q265020563.htm

<Button Height="143" HorizontalAlignment="Left" Margin="30,34,0,0" Name="button1" VerticalAlignment="Top" Width="145"> <Button.Background><ImageBrush ImageSource="图片路径" Stretch="Fill"/><Button.Background/></Button>为按钮 添加 背景图片 并 将图片 填满按钮 这种事XAML方式的 还有 C#方式的 原理都一样 都是 去针对 BACKGROUND属性进行 *** 作


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11737136.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存