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 } }
                };

c#代码使用ResourceDictionary样式,布布扣,bubuko.com

时间: 2024-12-17 10:06:34

c#代码使用ResourceDictionary样式的相关文章

各种各样的文本框滚动栏样式代码 滚动栏样式 文本框样式(文本框样式大全)

<div style="WIDTH: 148; HEIGHT: 146; BACKGROUND-COLOR: transparent; OVERFLOW: scroll; scrollbar-face-color: #FFFFFF; scrollbar-shadow-color: #885C10; scrollbar-highlight-color: #F8ECD8; scrollbar-3dlight-color: #885C10; scrollbar-darkshadow-color:

关于SeekBar的一些问题?用代码设置SeekBar样式出现问题

布局文件如下: 在SuKiSeekBar中 /** * 初始化 */ private void init(Context context) { this.context = context; SuKiObserver.getObserver().addObserver(this); setThumb(context.getResources().getDrawable(Theme.defSuKiSeekBarThumb)); //                setProgressDrawab

JSF根据控制层代码改变前端样式

使用jsf时,有时候需要在请求了控制层之后改变当前文本或者div的样式,页面无需写js代码,这里可以用一种方法来做到,在此做个记录.示例性代码如下: 1 <li class="#{bean.isTure?'a':'b'}"> 2 <label>哈哈</label> 3 </li> 根据bean中的isTrue方法返回的值,做一个三目运算来选择相应的class即可.

无代码软件开发样式文件导入新项目

腾讯课堂搜"尚识"在线学习无代码开发中,样式文件及LOGO,UI元件等是放在项目文件夹(开发工具默认文件夹名称是workspace)下的web文件夹中的,新项目模板中默认预定义了一套样式文件可以直接用,如果开发时添加了新的类或修改了默认的样式,则可以将其作为成熟项目的样式文件复用到新项目中:复制一个项目的样式文件,添加到新项目中 从一个项目中复制样式文件夹到新项目主要2步完成: 第一步:复制项目中样式文件夹注意上图是workspace中的TEST项目下的web样式文件夹.第二步:新项目

5、通过js代码设置css样式

1.页面 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv=&

3.通过js代码设置css样式

1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="

怎样在Word中插入代码并保持代码原始样式不变

怎样在Word中插入代码并保持样式不变 我们有时候需要在word中添加一段我们写的代码,但是把代码粘贴到word文档中之后就发现所有的代码的样子都变了,我们可以采用下边的方法来实现保持代码原来的样式和颜色高亮 1.这种方法适合于讲Visual Studio中的代码粘贴到word文档中 a.在word中选择插入选项卡,然后点击对象 b.在弹出的窗口中选择OpenDocument文本,之后会弹出一个新的word窗口,将Visual Studio中的代码复制粘贴到这里保存关闭窗口即可 c.效果图如下

60秒验证码倒计时js代码 js样式代码 方块上下左右随机移动(定时器) js中获取元素的方法 js中表单提交

60秒验证码倒计时js代码 <script type="text/javascript"> var countdown=60; function settime(val) { if (countdown == 0) { //removeAttribute() 方法删除指定的属性. disabled属性规定应该禁用 input 元素. val.removeAttribute("disabled"); val.value="免费获取验证码"

windows phone8.1样式

就像在html中使用css一样,在XAML元素中应用style可以对界面进行美化. 在控件Resource属性里面创建样式 <StackPanel> <StackPanel.Resources> <Style x:Key="commonStyle" TargetType="Button"> <Setter Property="Width" Value="200"></Set