找回密码
 立即注册

QQ登录

只需一步,快速开始

zxc9089
中级会员   /  发表于:2014-12-12 16:20  /   查看:11941  /  回复:12
C1ToolbarButton 如何设置鼠标划过变色的颜色单一而不是渐变色?

我给它设置了MouseOverBrush="CornflowerBlue" 他的效果如下:



显示的是两种颜色。 我实际需要的是 上部分和下部分是同样的颜色。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

12 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2014-12-12 18:39:00
沙发
回复 1楼zxc9089的帖子

可以尝试更改 C1 控件的 Theme 来保持鼠标hover格式的统一:

  1.         C1.WPF.Theming.C1Blue.C1ThemeC1Blue theme=new C1.WPF.Theming.C1Blue.C1ThemeC1Blue();
  2.         theme.Apply(this.c1toolbar1);
复制代码
回复 使用道具 举报
zxc9089
中级会员   /  发表于:2014-12-16 16:55:00
板凳
回复 2楼iceman的帖子

我的意思不是为了保持hover的统一。  如下图:


图标hover时, 上面的部分是浅蓝色,下面的部分是深蓝色。这个有没有办法只设置它为一种颜色? 不需要一深一浅。
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2014-12-16 18:02:00
地板
回复 3楼zxc9089的帖子

这个是WPF平台下所有button默认的效果,会有渐变的样式。
你可以先给button换个样式,比如C1ThemeOffice2007Blue,然后再设置MouseOverBrush。
代码参考:
  1.             C1.WPF.Theming.Office2007.C1ThemeOffice2007Blue theme = new C1.WPF.Theming.Office2007.C1ThemeOffice2007Blue();
  2.             theme.Apply(this.c1ToolbarButton1);
复制代码

Theme有很多种,可以通过添加dll到工程里使用,你选择一种需求的Theme替换掉WPF平台下默认的。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
zxc9089
中级会员   /  发表于:2014-12-17 15:03:00
5#
回复 4楼Alice的帖子

你好 ,我按照你们的方式对toolbar设置Theme后还是不起作用。 下面是我的demo文件:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2014-12-17 15:06:00
6#
回复 5楼zxc9089的帖子

Demo已经下载,需要安排测试,大概在下班前给您个反馈。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2014-12-17 18:45:00
7#
回复 5楼zxc9089的帖子

你的Demo已经查阅。
首先,你需要添加该Theme的引用,然后才能使用该Theme。
C1提供的Theme都在如下路径:
C:\Program Files (x86)\ComponentOne\Studio for WPF\bin\v4

C1.WPF.Theming的所有相关dll。

添加Theming相关dll后,就可以用楼上代码使用。

Themes的文档:
http://helpcentral.componentone. ... cuments/theming.htm
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
zxc9089
中级会员   /  发表于:2014-12-18 10:18:00
8#
我的demo在xaml的cs文件里面有引用Theme的, 还是没有效果。
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2014-12-18 13:58:00
9#
回复 8楼zxc9089的帖子

在MainWindow.xmal.cs以及MoudulesModel.cs还有App.xmal.cs均未能找到Theme的设置代码,另外引用里面也没有引用相关的Theme的dll。
Theme的添加步骤为,首先将相关Theme的dll添加到工程中,然后才可以使用。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
zxc9089
中级会员   /  发表于:2014-12-23 10:47:00
10#
  可能你下载错了。。 直接帖代码吧。。。

  1. namespace Wpfdemo
  2. {
  3.     /// <summary>
  4.     /// MainWindow.xaml 的交互逻辑
  5.     /// </summary>
  6.     public partial class MainWindow : Window
  7.     {
  8.         private MainViewModel _vm;
  9.         public MainWindow()
  10.         {
  11.             _vm = new MainViewModel();
  12.             DataContext = _vm;
  13.             InitializeComponent();


  14.             C1.WPF.Theming.C1Blue.C1ThemeC1Blue theme = new C1.WPF.Theming.C1Blue.C1ThemeC1Blue();
  15.             theme.Apply(this.FileToolBar);

  16.         }
  17.     }
  18. }
复制代码



  1. <Window x:Class="Wpfdemo.MainWindow"
  2.         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3.         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4.         xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
  5.         xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
  6.         Title="MainWindow" Height="350" Width="525">
  7.     <Window.Resources>

  8.         <Style TargetType="c1:C1ToolbarButton" x:Key="ctbButton">
  9.             <Setter Property="Width" Value="Auto"></Setter>
  10.             <Setter Property="MinWidth" Value="52"></Setter>
  11.             <Setter Property="Height" Value="58"></Setter>
  12.             <Setter Property="ToolTip" Value="工具栏"></Setter>
  13.             <Setter Property="Background" Value="Transparent"/>
  14.             <Setter Property="Foreground" Value="#333" />
  15.             <Setter Property="VerticalAlignment" Value="Stretch"/>
  16.             <Setter Property="Margin" Value="0,0,0,0"></Setter>
  17.         </Style>
  18.         <Style TargetType="Image" x:Key="ToolIcon">
  19.             <Setter Property="Width" Value="28" />
  20.             <Setter Property="Height" Value="35" />
  21.         </Style>
  22.     </Window.Resources>
  23.     <Grid>
  24.         <c1:C1Toolbar Name="FileToolBar" BorderThickness="0,0,0,1" BorderBrush="#b5bac0" ShowCollapseButton="True"
  25.                        ShowHelpButton="True" Padding="10,0,0,10"
  26.                       Height="77" VerticalContentAlignment="Center" VerticalAlignment="Center" Background="#f9f9fa" HorizontalAlignment="Stretch" >
  27.             <c1:C1ToolbarStrip  Height="77"  ItemsSource="{Binding ToolBtnList}" Background="Transparent">
  28.                         <c1:C1ToolbarButton Style="{StaticResource ctbButton}" MouseOverBrush="Bisque" Cursor="Hand">
  29.                             <StackPanel Orientation="Vertical" Width="52" >
  30.                                 <Image Source="print.png" Style="{StaticResource ToolIcon}"/>
  31.                                 <TextBlock Text="打印" HorizontalAlignment="Center" Margin="0,3,0,0"></TextBlock>
  32.                             </StackPanel>
  33.                         </c1:C1ToolbarButton>
  34.             </c1:C1ToolbarStrip>
  35.         </c1:C1Toolbar>
  36.     </Grid>
  37. </Window>

复制代码



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部