Telerik Forums
UI for WPF Forum
5 answers
537 views
Hi,
I've been trying to use IDataErrorInfo with the RagGridView, and i ran into some problems.
First of all i haven't been able to find any documentation on RadGridView support for IDataErrorInfo.
there was a single post on the forum that mentioned working with it - and it does work to a certain extent.

What im doing is this: i implemented IDataErrorInfo on in my data model, and i am binding to the grid with ValidatesOnDataErrors="True"
The binding code is:
<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> 

When scrolling down on the grid everything works as it should - a red border around the invalid data elements shows that there's an error there and the error appears around the correct elements and does not appear around valid elements.

The problem starts when i scroll UP in the grid. as soon as i scroll up everything starts failing - error markers start appearing around all elements regardless of their validity. after scrolling 20-30 records up it doesnt matter what i do - scroll up or down, everything seems to have an error and the boarders start drawing in the wrong place, sometimes over the text of the cells in the grid.

is this the right way to use IDataErrorInfo with Telerik's RadDataGrid?
Is there some other way (but still using IDataErrorInfo binding)?
What is causing this strange behavior?
Also - how do i get the grid to show a tooltip when hovering over an element with an error (with the string that returned from IDataErrorInfo as the error message).

Thanks,
Yossi.



EDIT:

After the above post i thought i'd try a simple test project outside of the rest of our app.
What i found was this - If we bind directly to a property of a class - validation is not called.
If we bind indirectly (through a nested element) - validation is called, but the strange "up/down" behavior i mentioned above occurs.
I am attaching my test project.
Scroll up and down on the "Nested" grid to see the errors i mentioned, the "Direct" grid demonstrates that the validation code is never called.

Hmm...looks like i can't attach the project - so here is the source:
Window1.xaml:

<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> 
 


Window1.cs.xaml Code:
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(thisnew PropertyChangedEventArgs("Name")); 
            } 
        } 
        private String bindingType; 
 
        public String BindingType 
        { 
            get { return bindingType; } 
            set { 
                bindingType = value; 
                if (this.PropertyChanged != null
                    this.PropertyChanged(thisnew 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; 
        } 
    } 
 

Kowsy
Top achievements
Rank 1
 answered on 27 Feb 2012
2 answers
99 views
Hi,

I am trying to embed a DataForm inside the LargeContent section of RadFluidContentControl. Entire user control is databound to an ObservableCollection of Address object, and Tile view shows the address objects properly. When I maximize one, RadDataForm is also shown properly.

My question is, how can I bind the DataForm to that tile's address object?

Can anybody help me with a simple example project? (VB, if possible please...)

Thanks,
Ahmet
Top achievements
Rank 1
 answered on 27 Feb 2012
2 answers
102 views
Hi,

Is it possible to drag and drop a TileViewItem to another control? Could you please post a sample wpf application?

I have been trying to implement this without any luck so far.

Thanks.
Ahmet
Top achievements
Rank 1
 answered on 27 Feb 2012
2 answers
162 views
Hi, I'd like to keep the GridView in a continuous insert mode when the currently inserted row is valid and the user presses the Enter key.

Scenario:
A new row is being inserted into the GridView and the user presses the Enter key.  The inserted row's data is valid

Observed Behavior:
The GridView commits the edit and focus then is moved to the next focusable control on the GridView's parent user control.

Desired Behavior:
After the row is commited, I'd like the GridView to re-enter insert mode and preselect (set focus to) the first cell.  In this way, a continuous data-entry mode can be provided.

How can I accomplish this?  Thanks!
Calvin
Top achievements
Rank 2
 answered on 27 Feb 2012
4 answers
171 views
Hi

How can I protect a ReadOnly Ranges from being removed via the UI?
It's impossible to remove something inside the range itself
via the UI - that's nice.
But when for example selecting the whole document's content (Ctrl+A)
and removing it (DEL) the readonly ranges are also removed.
Generally anytime when the ROR is contained inside a selection and the
edges of the selection aren't part of the ROR, it can be removed.

Is there a way to supress it?
Can I protect parts of a document against editing/removal?


Greetings,
Chris
Iva Toteva
Telerik team
 answered on 27 Feb 2012
2 answers
619 views
Question 1: How do I make the WPF PDFViewer toolbar show?

I currently have the following xaml:

<Grid  x:Name="LayoutRoot" DataContext="{StaticResource DataContext}">
    <telerik:RadPdfViewer x:Name="pdfViewer" DocumentSource="A10000292S_Notice.pdf" />
</Grid>

This xaml is in a System.Windows.Window.

Question 2: There is a "DocumentSource" property that I am successfully using, but what is the "Document" property for?

Thanks in advance.
Kellie Harrisson
Sierra Systems, Edmonton
Kammen
Telerik team
 answered on 27 Feb 2012
1 answer
90 views
If I simply add a gridview and leave all the default properties, then try and populate it with this simple code:

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



Pavel Pavlov
Telerik team
 answered on 27 Feb 2012
3 answers
107 views
Following the demo on GridView settings, I'm saving the declared column visibility when the user control loads. The user can then toggle which columns in the grid they want to see (and export). If they have gotten to a point where they want to reset all the columns back to the default (not all columns are visible by default), I have a link to reset the visibility, by loading the initial saved settings. This works the first time they click on it.

Let's say they then change visibility again and again want to reset, it doesn't work. I'm guessing it's because the persistence manager thinks it's already loaded? How do I get it to re-load? I could do it the manual way, but I want to use persistence because I anticipate them wanting to keep these settings between sessions, so I might eventually persist to a file.
Rayne
Top achievements
Rank 1
 answered on 27 Feb 2012
3 answers
163 views
Is there a way to have scheduleView timeline group day day, week, month, quarter in a way that the user can specify the grouping they want.  Attached is a proposed mockup of what i'm trying to accomplish.
Yana
Telerik team
 answered on 27 Feb 2012
1 answer
53 views

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"/>






Vanya Pavlova
Telerik team
 answered on 27 Feb 2012
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?