• 将toolbar 按钮中的图片弄成灰色的


    当然是要随着 CommandBinding 的 Command 一起联动了。

    这么做的:

    搞一个 Style,在里面搞个触发器,触发器的两边分别是:包含图片的button的IsEnabled属性 和 False,当button不可用的时候,就把图片的 透明度弄低。

            <ToolBar Name="toolBarPanel1" VerticalAlignment="Top" Height="76" Margin="0,24,0,0" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">            
                
    <ToolBar.Resources>
                    
    <Style TargetType="{x:Type Image}" x:Key="toolbarImageStyle">
                        
    <Style.Triggers>
                            
    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
                                
    <Setter Property="Opacity" Value="0.20"></Setter>
                            
    </DataTrigger>
                        
    </Style.Triggers>
                    
    </Style>
                
    </ToolBar.Resources>
                
    <Button Height="70" HorizontalAlignment="Left" Name="btnOpenFile" VerticalAlignment="Top" Width="70" Command="ApplicationCommands.Open" ToolTip="打开项目">
                   
    <Image  Source="/ZippyWPFForm;component/icons/open.png" HorizontalAlignment="Left" Style="{StaticResource toolbarImageStyle}"></Image>
                
    </Button>
            
    </ToolBar>
  • 相关阅读:
    九、一级缓存、二级缓存
    八、懒加载
    七、一对一、一对多、多对多
    六、通过mapper接口加载映射文件
    五、动态SQL
    c# ie 设置radio选中状态
    MySQL ----数据库操作
    起点
    Java的三大特性总结
    dom4j操作xml
  • 原文地址:https://www.cnblogs.com/cloudbeer/p/1519336.html
Copyright © 2020-2023  润新知