首页 > 代码库 > c#代码使用ResourceDictionary样式
c#代码使用ResourceDictionary样式
对于ResourceDictionary样式代码:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">... <Style x:Key="AlertButton" TargetType="ButtonBase" BasedOn="{StaticResource SystemButtonBase}"> <Setter Property="Cursor" Value="Hand" /> <Setter Property="Margin" Value="8"/> <Setter Property="Padding" Value="4"/> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Cursor" Value="Hand"></Setter> <Setter Property="Opacity" Value=".8" /> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter Property="Opacity" Value=".4" /> </Trigger> </Style.Triggers> </Style>...</ResourceDictionary>
使用C#代码引用:
ResourceDictionary mystyles; mystyles = new ResourceDictionary(); mystyles.Source = new Uri("/FirstFloor.ModernUI;component/Assets/Button.xaml", UriKind.RelativeOrAbsolute); System.Windows.Style btnStyle = mystyles["AlertButton"] as Style; new Button { Foreground = new SolidColorBrush(Colors.White), Content = content, Command = this.CloseCommand, CommandParameter = result, IsDefault = false, IsCancel = isCancel, MinHeight = 21, MinWidth = 65, Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(252, 73, 0)), Margin = new Thickness(4, 0, 4, 0) , Style = new Style(typeof(Button), btnStyle) { Triggers = { tRed } } };
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。