【问题标题】:UWP Telerik RadDataGrid not allowing me to end row edit by hitting enterUWP Telerik RadDataGrid 不允许我按回车键结束行编辑
【发布时间】:2017-11-22 19:11:47
【问题描述】:

我在结束 Telerik 的 UWP RadDataGrid 中的一行编辑时遇到问题。填充数据后,我单击一个单元格开始编辑。在我完成编辑该行后,我按 Enter 完成编辑,但它仍处于编辑模式。单击另一行中的单元格结束编辑,新数据保持不变,但绑定的集合不会更新。下面是我正在使用的网格的屏幕截图: 这是我页面中的 XAML 代码:

<tg:RadDataGrid ColumnDataOperationsMode="Flyout"  x:Name="grid" ItemsSource="{x:Bind ViewModel.Source}" UserEditMode="Inline"  Grid.ColumnSpan="4" Grid.Row="1"/>

非常感谢您的帮助。提前非常感谢!

【问题讨论】:

    标签: xaml uwp telerik grid uwp-xaml


    【解决方案1】:

    完成编辑行后,我按 Enter 完成编辑,但仍处于编辑模式。

    我创建了一个 16299 UWP 项目来测试并为其安装了Telerik.UI.for.UniversalWindowsPlatform(1.0.0.7) 包。然后,我可以重现这个问题。但是如果我将项目的目标版本更改为“15063”,当我点击Enter 键时,它将成功提交编辑操作。所以,这个 Telerik 控件在 16299 中运行时可能会出现一些问题。您可以将此问题报告给他们的 Telerik 官方网站。

    而且由于UWP的Telerik控件是开源的,你也可以查看它的源代码并自己修复这个问题,然后你可以自己编译你的自定义版本并在你的项目中使用它。

    我在这行代码中看到了关于这个问题的相关代码:https://github.com/telerik/UI-For-UWP/blob/master/Controls/Grid/Grid.UWP/View/RadDataGrid.Manipulation.cs#L392也许,你可以检查一下。

    单击另一行中的单元格结束编辑,新数据完好无损,但绑定的集合不会更新。

    我没有看到你的代码,所以我不知道问题出在哪里。但这对我来说效果很好。您可以查看我的简单代码示例以供参考:

    <telerikGrid:RadDataGrid x:Name="DataGrid" ItemsSource="{x:Bind ls}" UserEditMode="Inline"></telerikGrid:RadDataGrid>
    
    public sealed partial class MainPage : Page
    {
        public ObservableCollection<Data> ls { get; set; }
        public MainPage()
        {
            this.InitializeComponent();
            ls = new ObservableCollection<Data>() {new Data { Country = "India", Capital = "New Delhi"},
     new Data { Country = "South Africa", Capital = "Cape Town"},
     new Data { Country = "Nigeria", Capital = "Abuja" },
     new Data { Country = "Singapore", Capital = "Singapore" }  };
        }
    }
    
    public class Data:INotifyPropertyChanged
    {
        private string _Country;
        public string Country
        {
            get { return _Country; }
            set
            {
                _Country = value;
                RaisePropertyChange("Country");
            }
        }
    
        private string _Capital;
        public string Capital
        {
            get { return _Capital; }
            set
            {
                _Capital = value;
                RaisePropertyChange("Capital");
            }
        }
    
        public event PropertyChangedEventHandler PropertyChanged;
    
        public void RaisePropertyChange(string propertyName)
        {
            if (PropertyChanged!= null)
            {
                PropertyChanged(this,new PropertyChangedEventArgs(propertyName));
            }
        }
    }
    

    【讨论】:

    • Xavier,非常感谢您抽出宝贵时间进行详细回复。我会在星期一调查这个。感恩节快乐!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-04
    • 1970-01-01
    • 1970-01-01
    • 2022-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多