or
| <controls:RadGridView Name="keywordGrid" ShowGroupPanel="False" AutoGenerateColumns="False" Height="300" |
| > |
| <controls:RadGridView.Columns> |
| <controls:GridViewDataColumn Header="Name" DataMemberBinding="{Binding DeferredEntity.Data.Name, ValidatesOnDataErrors=True}"/> |
| <controls:GridViewDataColumn Header="Destination Url" DataMemberBinding="{Binding DeferredEntity.Data.DestinationUrl, ValidatesOnDataErrors=True}"/> |
| <controls:GridViewDataColumn Header="Tracking Url" DataMemberBinding="{Binding DeferredEntity.Data.TrackingUrl, ValidatesOnDataErrors=True}"/> |
| <controls:GridViewDataColumn Header="Match Type" DataMemberBinding="{Binding DeferredEntity.Data.MatchType, ValidatesOnDataErrors=True}"/> |
| <controls:GridViewDataColumn Header="Status" DataMemberBinding="{Binding DeferredEntity.Data.Status, ValidatesOnDataErrors=True}"/> |
| <controls:GridViewDataColumn Header="Search Bid" DataMemberBinding="{Binding DeferredEntity.Data.SearchBid, ValidatesOnDataErrors=True}"/> |
| </controls:RadGridView.Columns> |
| </controls:RadGridView> |
| <Window x:Class="GridIDataErrorInfoTest.Window1" |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| xmlns:Telerik="http://schemas.telerik.com/2008/xaml/presentation" |
| xmlns:controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" |
| xmlns:grid="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView" |
| xmlns:gridView="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView" |
| Title="Window1" Height="800" Width="600"> |
| <Grid> |
| <Grid.RowDefinitions> |
| <RowDefinition Height="300"/> |
| <RowDefinition Height="300"/> |
| </Grid.RowDefinitions> |
| <controls:RadGridView Grid.Row="0" Name="directGrid" ShowGroupPanel="False" AutoGenerateColumns="False" Height="300" |
| > |
| <controls:RadGridView.Columns> |
| <controls:GridViewDataColumn Header="Name - DirectBinding" DataMemberBinding="{Binding Name, ValidatesOnDataErrors=True}"/> |
| <controls:GridViewDataColumn Header="Binding Type - DirectBinding" DataMemberBinding="{Binding BindingType, ValidatesOnDataErrors=True}"/> |
| </controls:RadGridView.Columns> |
| </controls:RadGridView> |
| <controls:RadGridView Grid.Row="1" Name="nestedGrid" ShowGroupPanel="False" AutoGenerateColumns="False" Height="300" |
| > |
| <controls:RadGridView.Columns> |
| <controls:GridViewDataColumn Header="Name - NestedBinding" DataMemberBinding="{Binding Test.Name, ValidatesOnDataErrors=True}"/> |
| <controls:GridViewDataColumn Header="Binding Type - NestedBinding" DataMemberBinding="{Binding Test.BindingType, ValidatesOnDataErrors=True}"/> |
| </controls:RadGridView.Columns> |
| </controls:RadGridView> |
| </Grid> |
| </Window> |
| using System; |
| using System.Collections.Generic; |
| using System.Linq; |
| using System.Text; |
| using System.Windows; |
| using System.Windows.Controls; |
| using System.Windows.Data; |
| using System.Windows.Documents; |
| using System.Windows.Input; |
| using System.Windows.Media; |
| using System.Windows.Media.Imaging; |
| using System.Windows.Navigation; |
| using System.Windows.Shapes; |
| using System.ComponentModel; |
| using System.Diagnostics; |
| namespace GridIDataErrorInfoTest |
| { |
| public class DeeperBinding |
| { |
| private TestData test; |
| public TestData Test |
| { |
| get { return test; } |
| set { test = value; } |
| } |
| } |
| public class TestData : IDataErrorInfo,INotifyPropertyChanged |
| { |
| private String name; |
| public String Name |
| { |
| get { return name; } |
| set { |
| name = value; |
| if (this.PropertyChanged != null) |
| this.PropertyChanged(this, new PropertyChangedEventArgs("Name")); |
| } |
| } |
| private String bindingType; |
| public String BindingType |
| { |
| get { return bindingType; } |
| set { |
| bindingType = value; |
| if (this.PropertyChanged != null) |
| this.PropertyChanged(this, new PropertyChangedEventArgs("BindingType")); |
| } |
| } |
| #region IDataErrorInfo Members |
| public string Error |
| { |
| get { |
| return null; |
| } |
| } |
| public string this[string columnName] |
| { |
| get |
| { |
| Debug.WriteLine("Calling validation - BindingType = "+this.bindingType); |
| if (!columnName.Equals("Name")) |
| return null; |
| if (this.name.Equals("MyErrorValue")) |
| return "Error !!! WAAHAHAHAHA"; |
| else |
| return null; |
| } |
| } |
| #endregion |
| #region INotifyPropertyChanged Members |
| public event PropertyChangedEventHandler PropertyChanged; |
| #endregion |
| } |
| /// <summary> |
| /// Interaction logic for Window1.xaml |
| /// </summary> |
| public partial class Window1 : Window |
| { |
| public Window1() |
| { |
| InitializeComponent(); |
| //direct binding ignores validation |
| this.directGrid.ItemsSource = GenerateTestData("Direct"); |
| //binding to a nested element calls validation on the nested elements, but does not work properly. |
| this.nestedGrid.ItemsSource = WrapInDeeperBinding(GenerateTestData("Nested")); |
| } |
| private List<TestData> GenerateTestData(String bindingType) |
| { |
| int count = 10000; |
| List<TestData> result = new List<TestData>(); |
| for (int i = 0; i < count; i++) |
| if (i % 2 == 0) |
| result.Add(new TestData() { Name = "grgrbgrb", BindingType = bindingType}); |
| else |
| result.Add(new TestData() { Name = "MyErrorValue", BindingType = bindingType }); |
| return result; |
| } |
| private List<DeeperBinding> WrapInDeeperBinding(List<TestData> dataList) |
| { |
| List<DeeperBinding> result = new List<DeeperBinding>(); |
| foreach(var data in dataList) |
| result.Add(new DeeperBinding(){Test = data}); |
| return result; |
| } |
| } |
| } |
<Grid x:Name="LayoutRoot" DataContext="{StaticResource DataContext}"> <telerik:RadPdfViewer x:Name="pdfViewer" DocumentSource="A10000292S_Notice.pdf" /> </Grid> 
private void Window_Loaded(object sender, RoutedEventArgs e)
{
List<string> strings = new List<string>();
radGridView1.ItemsSource = strings;
strings.Add("a");
strings.Add("b");
strings.Add("c");
radGridView1.Items.Refresh();
}
The rows do not appear until I click a column header to re-order that column. As Items.Refresh() does not work what can I call to make the rows appear?
I know using an ObservableCollection rather than list<string> will work, but I can't do that in this situation.
thanks
Hi,
I have two styling issues wtih the GridView. The first is I am trying to by default set a column style to not display the Filter for a column by default (we only have a few columns in each grid that are filterable). My code is as follows:
<Style TargetType="telerik:GridViewColumn" > <Setter Property="IsFilterable" Value="False"/> </Style>Second, I have a cell style set as well but I now when I set the Background brush for a column it has no affect. What am I doing wrong?
<Style TargetType="telerik:GridViewCell" > <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type telerik:GridViewCell}"> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/> </Border> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="BorderBrush" Value="#FFEFEFEF" /> <Setter Property="BorderThickness" Value="0,0,1,0" /> <Setter Property="Margin" Value="2,0,0,0"/> <Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="HorizontalAlignment" Value="Stretch"/> </Style>In the gridview I am setting the background as such:
Any help would be greatly appreciated!
David A.
<telerik:GridViewDataColumn DataMemberBinding="{Binding HoursCompleted}" Header="Hours" UniqueName="HoursCompleted" DataFormatString=" {0:n2}" HeaderTextAlignment="Center" Width="60" Background="#33FDA500"/>