or
<Grid Margin="10"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Button Content="Test" Click="Button_Click" /> <telerik:RadGridView Margin="0,10,0,0" Grid.Row="1" ItemsSource="{Binding Items}" AutoGenerateColumns="False" AlternationCount="2" AlternateRowBackground="#E6E3E3"> <telerik:RadGridView.Columns> <telerik:GridViewColumn Width="80" Header="ID"> <telerik:GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding ID}" VerticalAlignment="Center" HorizontalAlignment="Left" TextTrimming="CharacterEllipsis" /> </DataTemplate> </telerik:GridViewColumn.CellTemplate> </telerik:GridViewColumn> <telerik:GridViewColumn Width="80" Header="Data"> <telerik:GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Name}" VerticalAlignment="Center" HorizontalAlignment="Left" TextTrimming="CharacterEllipsis" /> </DataTemplate> </telerik:GridViewColumn.CellTemplate> </telerik:GridViewColumn> </telerik:RadGridView.Columns> </telerik:RadGridView> </Grid>public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { ((MainWindowViewModel)DataContext).Test2(); } private void Window_Loaded(object sender, RoutedEventArgs e) { DataContext = new MainWindowViewModel(); ((MainWindowViewModel)DataContext).Test1(); } }using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ComponentModel;namespace GridViewBug{ public class Stuff { public int ID { get; set; } 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 Test1() { Items = new List<Stuff>(); for (int i = 0; i < 100; i++) { Items.Add(new Stuff() { Name = "item" + i.ToString(), ID = i }); } } public void Test2() { var items = new List<Stuff>(); items.Add(new Stuff() { Name = "item1", ID = 1 }); items.Add(new Stuff() { Name = "item2", ID = 2 }); items.Add(new Stuff() { Name = "item3", ID = 3 }); Items = items; } }}WPF v2011.2.712.40
We have a grid showing a list of contacts with email addresses. If an email is not valid a UriFormatException is thrown when just hovering over the hyperlink or trying to click on the hyperlink. How can we trap this and stop the exception from being thrown? I looked for error events on the grid and could not find anything obvious.
<telerik:GridViewDynamicHyperlinkColumn Header="Email" NavigateUrlMemberPaths="EmailAddress" NavigateUrlFormatString="{} mailto:{0}" DataMemberBinding="{Binding EmailAddress}" />
<
telerik:GridViewComboBoxColumn
DataMemberBinding="{Binding Path=ActivityType}"
DisplayMemberPath="Name"
SelectedValueMemberPath="ID"
HeaderText="‘…‚ ”’‰…"
UniqueName="ActivityType" />
((
GridViewComboBoxColumn)this.RadGridView1.Columns[10]).ItemsSource = GetActivityTypes();
RadGridView1.ItemsSource = GetDataGrid();
Item="{Binding BindingObject,NotifyOnSourceUpdated=True,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"Basically, is there a way to refresh the Selected Category Items Pane, or a better way to bind the item dynamically?