Is this the best place to report bugs?
This is with 2024.4.1213.462.
To duplicate the issue:
- With VS 2022, create a WPF (.NET Framework) application,
- Delete MainWindow.xaml and MainWindow.xaml.cs
- Unzip the attached file, place MainWindow.xaml and MainWindow.xaml.cs from the zip where the old files were or use the pasted text below
- Build and run the application
- Put focus on a cell in a row in the grid and type a letter
Expect the following exception to be raised
Name | Value | Type | |
---|---|---|---|
◢ | $exception | {"Object reference not set to an instance of an object."} | System.NullReferenceException |
at Telerik.Windows.Controls.DateTimePickerGridViewEditor.Telerik.Windows.Controls.GridView.IGridViewEditor.SetText(String text) in Telerik.Windows.Controls\DateTimePickerGridViewEditor.cs:line 56
In case the zip doesn't work:
MainWindow.xaml.cs:
namespace WpfApp14
{
using System;
using System.ComponentModel;
using System.Windows;
using System.Collections.ObjectModel;
public sealed class GridValueViewModel : INotifyPropertyChanged
{
private string someValue = string.Empty;
public GridValueViewModel(string someValue)
{
this.SomeValue = someValue;
}
public event PropertyChangedEventHandler PropertyChanged;
public string SomeValue
{
get
{
return this.someValue;
}
set
{
value = value ?? string.Empty;
if (this.SomeValue != value)
{
this.someValue = value;
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.SomeValue)));
}
}
}
public DateTime? DateValue
{
get
{
if (DateTime.TryParse(this.SomeValue, out var value))
{
return value;
}
return null;
}
set
{
if (value == null)
{
this.SomeValue = string.Empty;
return;
}
this.SomeValue = value.ToString();
}
}
public ObservableCollection<string> SomeValueItems { get; } = new ObservableCollection<string>(
new[]
{
"cat",
"dog",
"bird"
});
}
public partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
this.DataContext = this;
}
public ObservableCollection<GridValueViewModel> Values { get; } = new ObservableCollection<GridValueViewModel>(
new[]
{
new GridValueViewModel("cat"),
new GridValueViewModel("dog"),
new GridValueViewModel("bird")
});
}
}
MainWindow.xaml:
<Window x:Class="WpfApp14.MainWindow"
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"
Title="MainWindow" Height="450" Width="800">
<telerik:RadGridView
AutoGenerateColumns="False"
ItemsSource="{Binding Values, Mode=OneWay}">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn
Header="Column 1">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<Label
Content="{Binding SomeValue}" />
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
<telerik:GridViewDataColumn.CellEditTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="*" />
</Grid.ColumnDefinitions>
<TextBox
Grid.Column="0"
Text="{Binding SomeValue, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
Visibility="Collapsed" />
<telerik:RadComboBox
Grid.Column="0"
HorizontalAlignment="Stretch"
IsEditable="False"
ItemsSource="{Binding SomeValueItems}"
SelectedItem="{Binding SomeValue}" />
<telerik:RadDateTimePicker
Grid.Column="0"
HorizontalAlignment="Stretch"
InputMode="DatePicker"
DateTimeWatermarkContent="{x:Null}"
SelectedValue="{Binding DateValue, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
Visibility="Collapsed" />
</Grid>
</DataTemplate>
</telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Window>
Maybe the dateTimePicker member field of the DateTimePickerGridViewEditor object is null when the SetText method is called.