<Window x:Class="GridViewBug.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" WindowState="Maximized" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded"> <telerik:RadGridView ItemsSource="{Binding Items}" Margin="20" AutoGenerateColumns="False"> <telerik:RadGridView.Columns> <telerik:GridViewColumn Width="300" Header="Data"> <telerik:GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Name}" TextWrapping="Wrap" /> </DataTemplate> </telerik:GridViewColumn.CellTemplate> </telerik:GridViewColumn> </telerik:RadGridView.Columns> </telerik:RadGridView></Window>using System.Windows;namespace GridViewBug{ public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { DataContext = new MainWindowViewModel(); ((MainWindowViewModel)DataContext).Test(); } }}using System.Collections.Generic;using System.ComponentModel;using System.Linq;using FizzWare.NBuilder;using FizzWare.NBuilder.Generators;namespace GridViewBug{ public class Stuff { public string Name { get; set; } } public class MainWindowViewModel : INotifyPropertyChanged { private PropertyChangedEventHandler _propertyChangedEvent; public event PropertyChangedEventHandler PropertyChanged { add { _propertyChangedEvent += value; } remove { _propertyChangedEvent -= value; } } protected virtual void NotifyPropertyChanged(string name) { PropertyChangedEventHandler handler = _propertyChangedEvent; if (handler != null) { handler(this, new PropertyChangedEventArgs(name)); } } private List<Stuff> _items; public List<Stuff> Items { get { return _items; } set { _items = value; NotifyPropertyChanged("Items"); } } public void Test() { string phrase = GetRandom.Phrase(130); Items = Builder<Stuff>.CreateListOfSize(70).All().With(x => x.Name = phrase).Build().ToList(); } }}<chart:RadCartesianChart Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="3" x:Name="AccountUsageChart" Height="500" Width="875" VerticalAlignment="Top" HorizontalAlignment="Center"> <chart:RadCartesianChart.HorizontalAxis> <chartView:CategoricalAxis HorizontalAlignment="Center" LabelFitMode="Rotate" Title="{Binding XAxisTitle, Mode=TwoWay}" Foreground="Gray" FontSize="15"/> </chart:RadCartesianChart.HorizontalAxis> <chart:RadCartesianChart.VerticalAxis> <chartView:LinearAxis Title="Usage" ElementBrush="#FF8EC441" FontSize="20"/> </chart:RadCartesianChart.VerticalAxis> <chart:RadCartesianChart.Grid> <chartView:CartesianChartGrid MajorLinesVisibility="Y" /> </chart:RadCartesianChart.Grid> <chartView:BarSeries CategoryBinding="XValue" ValueBinding="YValue" ItemsSource="{Binding BindingData}" CombineMode="Stack"> <telerik:BarSeries.PointTemplate> <DataTemplate> <Rectangle Fill="#FF8EC441"/> </DataTemplate> </telerik:BarSeries.PointTemplate> </chartView:BarSeries> <chartView:BarSeries CategoryBinding="XValue" ValueBinding="YValue" ItemsSource="{Binding ProjectedBindingData}" CombineMode="Stack" > <telerik:BarSeries.LegendSettings> <telerik:DataPointLegendSettings /> </telerik:BarSeries.LegendSettings> <telerik:BarSeries.PointTemplate> <DataTemplate> <Rectangle Fill="Gray"/> </DataTemplate> </telerik:BarSeries.PointTemplate> </chartView:BarSeries> <chartView:LineSeries Visibility="{Binding ShowLineSeriesTempChart, Converter={StaticResource boolToVisibility}}" CategoryBinding="XValue" ValueBinding="Temp" ItemsSource="{Binding BindingData}" Stroke="#FF1B9DDE" > <chartView:LineSeries.VerticalAxis> <chartView:LinearAxis Title="{Binding TemperatureAxisTitle, Mode=TwoWay}" ElementBrush="#FF1B9DDE" HorizontalLocation="Right" Visibility="{Binding ShowLineSeriesTempChart, Converter={StaticResource boolToVisibility}}" IsInverse="{Binding FlipTempYAxisVertically, Mode=TwoWay}" /> </chartView:LineSeries.VerticalAxis> </chartView:LineSeries> <chartView:CandlestickSeries ItemsSource="{Binding BindingData}" CategoryBinding="XValue" LowBinding="LowTemp" HighBinding="HighTemp" OpenBinding="LowTemp" CloseBinding="HighTemp" Visibility="{Binding ShowCandleStickTempChart, Converter={StaticResource boolToVisibility}}" > <chartView:CandlestickSeries.DefaultVisualStyle> <Style TargetType="chartView:Candlestick"> <Setter Property="MaxWidth" Value="10"/> <Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Visible"/> <Setter Property="UpFill" Value="#FF1B9DDE"/> <Setter Property="UpStroke" Value="#FF1B9DDE"/> <Setter Property="DownFill" Value="#FF1B9DDE"/> <Setter Property="DownStroke" Value="#FF1B9DDE"/> </Style> </chartView:CandlestickSeries.DefaultVisualStyle> <chartView:CandlestickSeries.VerticalAxis> <chartView:LinearAxis Title="{Binding TemperatureAxisTitle, Mode=TwoWay}" Visibility="{Binding ShowCandleStickTempChart, Converter={StaticResource boolToVisibility}}" ElementBrush="#FF1B9DDE" HorizontalLocation="Right"/> </chartView:CandlestickSeries.VerticalAxis> </chartView:CandlestickSeries> <telerik:RadCartesianChart.Behaviors> <telerik:ChartSelectionBehavior DataPointSelectionMode="Single" > <i:Interaction.Triggers> <i:EventTrigger EventName="SelectionChanged"> <ei:CallMethodAction MethodName="Bar_SelectionChanged" TargetObject="{Binding}" IsEnabled="True" /> </i:EventTrigger> </i:Interaction.Triggers> </telerik:ChartSelectionBehavior> </telerik:RadCartesianChart.Behaviors> </chart:RadCartesianChart>I use the RadComboBox from Telerik in a WPF project.
My Problem is that the selected text is not updated when the selected item changes its value. So when the ViewModel changes the `Name` property of the `SelectedItem`, I can not see this in the RadComboBox.
Note: The `SelectedItem` implements `INotifyPropertyChanged` and is calling the event.
Full source code:
public class MainViewModel : INotifyPropertyChanged{ private readonly List<Item> _items = new List<Item>(); private Item _selectedItem; public MainViewModel() { _items.Add(new Item { Name = "Eg Zomh JywS" }); _items.Add(new Item { Name = "Ua Qvp Lavwz" }); _items.Add(new Item { Name = "Nee Lzx Rdaq" }); _items.Add(new Item { Name = "Um Ztgi Yvsg" }); _items.Add(new Item { Name = "tma Oppt fzd" }); _items.Add(new Item { Name = "Du Zofcy Fbs" }); _items.Add(new Item { Name = "bc Ey Ppvvcp" }); _items.Add(new Item { Name = "Mv RSIZtf WE" }); _items.Add(new Item { Name = "BFb YYZ PHwC" }); _items.Add(new Item { Name = "YSW LQ DXxHu" }); } public event PropertyChangedEventHandler PropertyChanged; public IEnumerable<Item> Items { get { return _items; } } public Item SelectedItem { get { return _selectedItem; } set { _selectedItem = value; OnPropertyChanged("SelectedItem"); OnPropertyChanged("SelectedItemName"); } } public string SelectedItemName { get { return _selectedItem != null ? _selectedItem.Name : null; } set { if (_selectedItem != null) { _selectedItem.Name = value; OnPropertyChanged("SelectedItemName"); } } } protected virtual void OnPropertyChanged(string propertyName) { var handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } }}
public class Item : INotifyPropertyChanged{ private string _name; public event PropertyChangedEventHandler PropertyChanged; public string Name { get { return _name; } set { _name = value; OnPropertyChanged("Name"); } } protected virtual void OnPropertyChanged(string propertyName) { var handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } }}
<Window x:Class="TelerikRadComboBoxProblem.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" Height="150" Width="300"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBlock Text="Search: " VerticalAlignment="Center" /> <telerik:RadComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding Items, Mode=OneWay}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" StaysOpenOnEdit="True" DisplayMemberPath="Name" CanAutocompleteSelectItems="False" IsEditable="True" IsReadOnly="False" OpenDropDownOnFocus="True" IsFilteringEnabled="True" TextSearchMode="Contains"> </telerik:RadComboBox> <TextBlock Grid.Row="1" Grid.Column="0" Text="Rename: " VerticalAlignment="Center" /> <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding SelectedItemName, Mode=TwoWay}" /> </Grid></Window>
public partial class MainWindow{ public MainWindow() { InitializeComponent(); DataContext = new MainViewModel(); }}Hello Telerik,
I am using version 2013.2.724.40 and I have the following problem. I’m working on an MVVM WPF application. It is a multi-thread application which draws data form a postgres db, displays the data and writes them in to a SQL EXPRESS DB. In one (two) View(s) the data can be displayed and manipulate in a RadGridView this is directly bound to a QueryableEntityCollectionView<>, I’m using the Microsoft Entity Framework.
Occasionally and absolutely not reproducible, but nonetheless too often I get an unhandled EntityCommandExecutionException, mostly when the user push a button to change the View. The Inner Exception is "A severe error occurred on the current command. The results, if any, should be discarded.". If this occurs in the Debugger and when I have a look at the stack, it looks like in the attached picture.
I have the suspicion that comes from the QueryableEntityCollectionView<> bound to the RadGridView, but I have no idea how to prevent this and/or on which place I should enclose some code with a try catch block.
As you can see in the stack none of my functions or classes are involved.
May be someone have an idea.
Regards Uwe