最近涉及到的一些需要备忘的东西

1.WPF ScrollViewer 关于设置滚动位置不起作用的解决办法

  首先需要调用UpdateLayout() 此时才会更新改变后(例如显示区域大小变化)等信息

  然后在调用scrollViewer.ScrollToHorizontalOffset(double d) 或者其他类似的方法即可

 

2.关于使用Excel作为数据源问题 出现“未在本地计算机上注册microsoft.ace.12.0”的问题

 首先确定你的机器是不是64位系统 如果是请将项目生成的目标平台改为x86

   若果还是出现该问题 请到去http://download.microsoft.com/download/7/0/3/703ffbcb-dc0c-4e19-b0da-1463960fdcdb/AccessDatabaseEngine.exe下载安装之后即可

 

3.DEVExpress For WPF 中Gridcontrol如何根据内容让整行变色

1 <Style x:Key = "RowStyle" BasedOn = "{StaticResource {dxgt:GridRowThemeKey ResourceKey=RowStyle}}" TargetType = "{x:Type dxg:GridRowContent}">
2              <Setter Property = "Background" Value="{Binding Row, Converter={StaticResource alarmLevelConverter}}"/>
3 <!--或者
4 <Setter Property = "Background" Value="{Binding Path=DataContext.字段名, Converter={StaticResource alarmLevelConverter}}"/>
5 --> </Style>

里面需要转换器 

 1      [ValueConversion(typeof(AlarmHappeningClass), typeof(Brush))]
 2   
 3       public class AlarmLevelConverter : IValueConverter
 4       {
 5   
 6           public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 7           {
 8               AlarmHappeningClass alarmrow = value as AlarmHappeningClass;
 9               if (alarmrow == null)
10                  return Brushes.Transparent; ;
11              if (alarmrow.AlarmLevel=="紧急")
12                  return Brushes.Red;
13              else if (alarmrow.AlarmLevel == "重要")
14                  return Brushes.Orange;
15              return Brushes.Transparent;
16          }
17  
18          public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
19          {
20              throw new NotSupportedException();
21          }
22  
23      }

这部分代码来自于http://www.bubuko.com/infodetail-508440.html

如果是绑定字段的话就不用那么麻烦了 value就是字段值

 

posted @ 2016-03-25 09:02  我丫的是条鱼  Views(312)  Comments(0Edit  收藏  举报