当RadGridView中嵌套RadComboBox,且RadGridView的高度不够出现滚动条时,上下拉动滚动条后,RadComboBox中的选中值将丢失!

  如下图:

  滚动条未拖动前

  

  滚动条上下拖动后(注意下图的高亮部分)

  

  重现该Bug的测试代码:

  Model层

  TextValueObject.cs

namespace RadControlsBug.Model
{
    public class TextValueObject
    {
        public string Text { set; get; }
  
        public string Value { set; get; }
    }
}

  SexType.cs

namespace RadControlsBug.Model
{
    public class SexType
    {
        /// <summary>
        /// 男
        /// </summary>
        public static string Male = "男";
  
        /// <summary>
        /// 女
        /// </summary>
        public static string FeMale = "女";
    }
}

  SexTypeCollection.cs

using System.Collections.Generic;
  
namespace RadControlsBug.Model
{
    public static class SexTypeCollection
    {
        private static List<TextValueObject> _items = new List<TextValueObject>();
  
        public static List<TextValueObject> Items
        {
            get { return _items; }
            set { _items = value; }
        }
  
        static SexTypeCollection() 
        {
            _items.Add(new TextValueObject() { Text = "男", Value = SexType.Male });
            _items.Add(new TextValueObject() { Text = "女", Value = SexType.FeMale });
        }
    }
}

  Person.cs

using System.Collections.Generic;
  
namespace RadControlsBug.Model
{
    public class Person
    {
        public string Name { set; get; }
  
        public string Sex { set; get; }
  
        private  List<TextValueObject> _sexItems = SexTypeCollection.Items;
  
        public List<TextValueObject> SexItems { get { return _sexItems; } }
  
    }
}

  Company.cs

using System.Collections.ObjectModel;
  
namespace RadControlsBug.Model
{
    public class Company
    {
        private ObservableCollection<Person> _employees = new ObservableCollection<Person>();
  
        public ObservableCollection<Person> Employees
        {
            get { return _employees; }
            set { _employees = value; }
        }
  
  
        public Company() 
        {
            this._employees.Add(new Person() { Name = "张三", Sex = SexType.Male });
            this._employees.Add(new Person() { Name = "李四", Sex = SexType.FeMale });
            this._employees.Add(new Person() { Name = "王五", Sex = SexType.Male });
            this._employees.Add(new Person() { Name = "赵六", Sex = SexType.FeMale });
            this._employees.Add(new Person() { Name = "孙七", Sex = SexType.Male });
            this._employees.Add(new Person() { Name = "杨九", Sex = SexType.FeMale });
            this._employees.Add(new Person() { Name = "胡十", Sex = SexType.Male });
        }
  
    }
}

  UI层:

  MainPage.Xaml:

<UserControl x:Class="RadControlsBug.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
  
    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
            <telerik:RadGridView ShowGroupPanel="False" RowIndicatorVisibility="Collapsed" CanUserFreezeColumns="False" AutoGenerateColumns="False" ItemsSource="{Binding Employees,Mode=TwoWay}" Width="300" Height="120" Name="gridView1">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewColumn   Header="姓名" Width="80" >
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <telerik:RadMaskedTextBox Value="{Binding Name,Mode=TwoWay}" MaskType="None"></telerik:RadMaskedTextBox>
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                    <telerik:GridViewColumn   Header="性别" Width="80" >
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <telerik:RadComboBox ItemsSource="{Binding SexItems,Mode=TwoWay}" SelectedValue="{Binding Sex,Mode=TwoWay}" SelectedValuePath="Value" DisplayMemberPath="Text"/>
                                  
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
             
        </StackPanel>
    </Grid>
</UserControl>

  MainPage.Xaml.cs:

using System.Windows;
using System.Windows.Controls;
using RadControlsBug.Model;
  
namespace RadControlsBug
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
  
            this.Loaded += new RoutedEventHandler(Page_Loaded);
        }
  
        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            Company _viewModel = new Company();
            this.DataContext = _viewModel;
              
        }
          
    }
}

  该问题曾经困扰我长达2周之久,在Telerik的论坛上提问也未得到回复。

  曾经反复尝试,发现解决方法居然极其简单:

  <telerik:RadComboBox ItemsSource="{Binding SexItems,Mode=TwoWay}" SelectedValue="{Binding Sex,Mode=TwoWay}" SelectedValuePath="Value" DisplayMemberPath="Text"/>

  改成:

  <telerik:RadComboBox  SelectedValue="{Binding Sex,Mode=TwoWay}" SelectedValuePath="Value" DisplayMemberPath="Text" ItemsSource="{Binding SexItems,Mode=TwoWay}"/>

  后,问题奇迹般的解决了!

  分享于此,希望有助于遇到同样问题的朋友。(个人分析:有可能telerik的开发人员在解析XAML时,判断逻辑依赖于属性出现的顺序导致--胡猜的,我也没去看它的源码)

  最后谈一下我个人对于Telerik RadControls For Silverlight这套控件的感受,用这套控件做项目开发已经有近3个月的时间,总体感觉还不错,能大幅提高团队的开发效率,官方有详细文档和示例, 上手非常容易,而且客观来讲,BUG也比较少(用了3个月,基本上才发现这一个比较诡异的BUG),此外,如果是正版用户,官方还提供源码,并有一年的免 费升级期限,每季度官方均会对整套控件做一次升级(主要是修复之前的BUG,以及增加一些新功能)。 从成本上考虑,一套控件的售价9k RMB左右(无Licence数量限制,而且能拿到源码任意修改),国内用户可在慧都控件网上直接购买,对于公司来讲这个成本其实并不高(相比公司招人自 己实现这些控件的功能而言,9k多其实可以忽略不计了),如果您的公司打算致力于企业级应用的RIA开发,建议使用。

Silverlight:telerik RadControls中RadGridView的一个Bug及解决办法(转载)的更多相关文章

  1. Excel在任务栏中只显示一个窗口的解决办法

     Excel在任务栏中只显示一个窗口的解决办法  以前朋友遇到过这个问题,这次自己又遇到了,习惯了以前的那种在任务栏中显示全部窗口,方便用Alt+Tab键进行切换. 如果同时打开许多Excel工作簿, ...

  2. asp.net开发中遇到的奇葩bug及解决办法(会持续更新。。。)

    1,不知道你们遇没遇到过,在vs2010或更高版本上运行程序的时候,完全没问题,放在IIS中出现了问题,就比如左侧是菜单项,点击菜单右边显示,如果菜单链接是这样:content.aspx,而另一个链接 ...

  3. 记CRenderTarget:DrawText()绘制中文乱码的BUG及解决办法

    原文:记CRenderTarget:DrawText()绘制中文乱码的BUG及解决办法 转载请注明出处:http://www.cnblogs.com/Ray1024 一.问题描述 在MFC中使用Dir ...

  4. 【转载】IE浏览器常见的9个css Bug以及解决办法

    IE浏览器常见的9个css Bug以及解决办法 我们在浏览网页的时候经常看见这样的现象:某个网页在IE6浏览器中打开很正常,但是在IE8里面打开可能完全变形了.或者也有可能出现完全相反的现象.这让We ...

  5. IIS关于“ 配置错误 不能在此路径中使用此配置节”的解决办法

    IIS关于“ 配置错误 不能在此路径中使用此配置节”的解决办法 原文链接:http://www.cnblogs.com/200325074/p/3679316.html 今天刚安装好IIS8.5, 我 ...

  6. 在ASP.net中的UpdatePanel,弹窗失败解决办法

    原文:在ASP.net中的UpdatePanel,弹窗失败解决办法 最开始我用: Response.Write("<script>alert('和哈呵呵呵呵呵呵!')</s ...

  7. 工作总结 EntityFramework中出现DateTime2异常的完美解决办法

    EntityFramework中出现DateTime2异常的完美解决办法   今天在使用entityframework往数据库插入数据的时候,突然出现了一个数据类型转换异常的问题: System.Da ...

  8. Dumpzilla工具第615行bug的解决办法

    Dumpzilla工具第615行bug的解决办法   在Dumpzilla使用选项frequency时,会提示SQL语法错误.这是由于其中SQL语句编写错误.需要将615行中: where url l ...

  9. Ubuntu中Android SDK Manager无法更新解决办法

    Ubuntu中Android SDK Manager无法更新解决办法http://hi.baidu.com/petercao2008/item/d7a64441f04668e81e19bc1a

随机推荐

  1. 【暴力】洛谷 P2038 NOIP2014提高组 day2 T1 无线网络发射器选址

    暴力枚举. #include<cstdio> #include<algorithm> using namespace std; ][],d,n,x,y,z,num,ans=-; ...

  2. Android 架构 4.总结

    以下是Keegan小钢大神原创博客: Android项目重构之路:架构篇Android项目重构之路:界面篇Android项目重构之路:实现篇 看了这几篇文章,以及下面的评论,总结一下,以便以后拓展: ...

  3. javascript 常用手势 分析

    javascript 常用手势, 个人觉得有3个 tap,swipe(swipeLeft,swipeRight,swipeTop,swipeRight),hold tap 是轻击 判断的原则是,在to ...

  4. WebApi_HelpPage

        HelpPage是描述WebApi接口信息的Web页,根据项目编译的Xml文件生成,包括接口的Router地址.请求参数.请求参数示例.响应参数.响应参数示例等,可方便调用方快速了解接口信息 ...

  5. VBA数组

    基础用法,这篇写的不错:https://www.cnblogs.com/wuzhiblog/p/7137578.html

  6. Oracle API Gateway SOAP到REST协议转换

    1.SOAP到REST协议转换 打开policystudio,加入一个policy Container. 搜索extract rest 设置成为start 搜索set message,将url中的变量 ...

  7. 一、ELKStack介绍与入门实践

    第1章 ELKStack 对于日志来说,最常见的需求就是收集.存储.查询.展示,开源社区正好有相对应的开源项目:logstash(收集).elasticsearch(存储+搜索).kibana(展示) ...

  8. javascript数据类型检测方法

    一.字符串.数字.布尔值.undefined的最佳选择市使用 typeof 运算符进行检测: 对于字符串,typeof 返回"string" 对于数字,typeof 返回" ...

  9. JavaScript面向对象总结

    对象(Object)应该算是js中最为重要的部分,也是js中非常难懂晦涩的一部分.更是面试以及框架设计中各出没.本文章,主要参考JavaScript红宝书(JavaScript高级程序设计 第六章)以 ...

  10. 依据出生日期Date 计算年龄

    依据出生日期计算年龄 public class DateGetAge { public static int getAge(Date birthDay) throws Exception { Cale ...