<!--按钮样式开始-->     <Style x:Key="NotifyBtnStyle" TargetType="{x:Type commondControl:ImgButton}">         <Setter Property="FocusVisualStyle"                 Value="{x:Null}" />         <Setter Property="Cursor" Value="Hand"/>         <Setter Property="Template">             <Setter.Value>                 <ControlTemplate TargetType="{x:Type commondControl:ImgButton}">                     <Grid Name="bg"                           Height="{TemplateBinding Height}"                           Width="{TemplateBinding Width}">                         <Grid.ColumnDefinitions>                             <ColumnDefinition Width="Auto" />                             <ColumnDefinition Width="*" />                         </Grid.ColumnDefinitions>                         <Image Name="ButtonImage"                                HorizontalAlignment="Center"                                VerticalAlignment="Center"                                Stretch="Fill"                                Width="{Binding ImageWidth,RelativeSource={RelativeSource TemplatedParent}}"                                Height="{Binding ImageHeight,RelativeSource={RelativeSource TemplatedParent}}"                                Source="{Binding ImageNormal,RelativeSource={RelativeSource TemplatedParent}}"                                />                         <TextBlock x:Name="text"                                    Grid.Column="1"                                    Text="{TemplateBinding Content}"                                    Margin="3,0,0,0"                                    Foreground="{TemplateBinding Foreground}"                                    HorizontalAlignment="Center"                                    VerticalAlignment="Center" />                     </Grid>

</ControlTemplate>             </Setter.Value>         </Setter>     </Style>

RelativeSource={RelativeSource TemplatedParent}的更多相关文章

  1. [WPF系列-高级TemplateBinding vs RelativeSource TemplatedParent]

    What is the difference between these 2 bindings: <ControlTemplate TargetType="{x:Type Button ...

  2. RelativeSource.TemplatedParent 属性wpf

    今天看到这一句代码时候,自己只是知道绑定了,可是不知道绑定了什么啊 就去查了一下,后来说的好像是绑定的TemplateParent返回的 一个值.可是这是为什么呢, 有的说是绑定的是一个资源. 下面有 ...

  3. 背水一战 Windows 10 (19) - 绑定: TemplateBinding 绑定, 与 RelativeSource 绑定, 与 StaticResource 绑定

    [源码下载] 背水一战 Windows 10 (19) - 绑定: TemplateBinding 绑定, 与 RelativeSource 绑定, 与 StaticResource 绑定 作者:we ...

  4. 绑定: TemplateBinding 绑定, 与 RelativeSource 绑定, 与 StaticResource 绑定

    介绍背水一战 Windows 10 之 绑定 TemplateBinding 绑定 与 RelativeSource 绑定 与 StaticResource 绑定 示例1.演示 TemplateBin ...

  5. 重新想象 Windows 8 Store Apps (52) - 绑定: 与 Element Model Indexer Style RelativeSource 绑定, 以及绑定中的数据转换

    [源码下载] 重新想象 Windows 8 Store Apps (52) - 绑定: 与 Element Model Indexer Style RelativeSource 绑定, 以及绑定中的数 ...

  6. WPF的控件Binding的ElementName/RelativeSource具体用法

    <TextBlock Name="_txtSickBedNo" FontStyle="Normal" Foreground="Black&quo ...

  7. Binding 中 Elementname,Source,RelativeSource 三种绑定的方式

    在WPF应用的开发过程中Binding是一个非常重要的部分. 在实际开发过程中Binding的不同种写法达到的效果相同但事实是存在很大区别的. 这里将实际中碰到过的问题做下汇总记录和理解. 1. so ...

  8. 在WPF中如何使用RelativeSource绑定

    在WPF绑定的时候,指定绑定源时,有一种办法是使用RelativeSource. 这种办法的意思是指当前元素和绑定源的位置关系. 第一种关系: Self 举一个最简单的例子:在一个StackPanel ...

  9. Binding RelativeSource

    IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}&q ...

随机推荐

  1. <2013 07 05> 804.15. 4--> TI MSP430+CC2520 调试

    这一周,实际参与eCar项目的工作正式展开. 来TUM的第一个月,主要熟悉了eCar的机电结构,特别是熟悉了eCar的IT(Information Technology),包括硬件和代码. 来的时候, ...

  2. JavaScript通过preventDefault()使input[type=text]禁止输入但保留光标

    一.说明 取消事件的默认动作. 该方法将通知 Web 浏览器不要执行与事件关联的默认动作(如果存在这样的动作).例如,如果 type 属性是 "submit",在事件传播的任意阶段 ...

  3. 解决table插入tr错位

    table中用JavaScript插入隐藏(即display="none";)的tr时,别用display="block";换成display="&q ...

  4. Java中volatile关键字实现原理

    原文地址http://www.cnblogs.com/xrq730/p/7048693.html,转载请注明出处,谢谢 前言 我们知道volatile关键字的作用是保证变量在多线程之间的可见性,它是j ...

  5. Python获取主机名

    import socket print socket.gethostname()

  6. Linux中接收键盘输入

    read 选项 变量名 -p    "提示信息" -t     指定等待时间,不指定则一直等待 -n    指定接收的字符数,不指定则不限制 -s    隐藏输入的数据,适用于机密 ...

  7. docker 批量导出脚本

    用for 循环实现 docker imagesREPOSITORY                                               TAG                 ...

  8. npm-folders

    npm-folders Executable(可执行程序) 在全局模式下,可执行程序被链接到Unix的{prefix}/bin目录下,或者是Windows的{prefix}目录下. 在本地模式下,可执 ...

  9. vs2015 安卓相关配置

    vs2015的安卓相关配置百度不到,园子里也没人写.还是我没搜索到? 看来只能靠自己的英(pin)语(yin)能力一点点解决了 安装2015这个过程没啥可说的.都安装就OK了. 重要的就是选择安卓程序 ...

  10. 【HackerRank】Sherlock and Array

    Watson gives an array A1,A2...AN to Sherlock. Then he asks him to find if there exists an element in ...