Telerik Forums
UI for WPF Forum
4 answers
207 views
Hello,

I'm facing some problems with CurrentRecord. I'm binding the object with CurrentRecord. I can't get the currentrecord from the code where I keep the object.

XAML

<UserControl x:Class="DevExpTest.PersonsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:model="clr-namespace:DevExpTest" 
    model:ObjectReference.Declaration="{model:ObjectReference window}"
    Height="419" Width="537" xmlns:my="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input">
    <UserControl.Resources>
        <ObjectDataProvider ObjectType="{x:Type model:PersonsViewModel}" x:Key="viewModel">
            <ObjectDataProvider.ConstructorParameters>               
                <model:ObjectReference Key="window"/>
            </ObjectDataProvider.ConstructorParameters>
        </ObjectDataProvider>
    </UserControl.Resources>
    <Grid>
        <my1:RadGridView Margin="0,10,28,43" Name="radGridView1"
                         xmlns:my1="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
                         ItemsSource="{Binding Source={StaticResource viewModel}, Path= GetData}"
                         CurrentRecord="{Binding Source={StaticResource viewModel}, Path= ActiveRecord}"
                         />
    </Grid>
</UserControl>

ViewModel

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.ComponentModel;

namespace DevExpTest {
    public class PersonsViewModel : INotifyPropertyChanged {
        private IView _iView;
        private ListCollectionView _persons;
        private Person _activeRecord;

        public PersonsViewModel() {
            loadData();
        }
        private void loadData(){
            List<Person> p = new List<Person>();
            p.Add(new Person(){ ID = 1, Name= "Michael Sync" });
            p.Add(new Person(){ ID = 1, Name= "Julia" });

            _persons = new ListCollectionView(p);

        }
        public PersonsViewModel(IView iv)
            : this() {
            _iView = iv;
        }
        public Person ActiveRecord {
            get {
                return _activeRecord;
            }
            set {
                _activeRecord = value;
                SendPropertyChanged("ActiveRecord");
            }
        }
        public ListCollectionView GetData {
            get {
                //_persons.Filter = obj => {
                //    return false;
                //};

                return _persons;
            }
        }

        #region Event Handlers

        /// <summary>
        /// This method raises the property changed event.
        /// </summary>
        /// <param name="propertyName">The property name which value has been changed</param>
        protected void SendPropertyChanged(string propertyName) {
            if (_propertyChanged != null) {
                _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler _propertyChanged;

        public event PropertyChangedEventHandler PropertyChanged {
            add {
                _propertyChanged += value;
            }
            remove {
                _propertyChanged -= value;
            }
        }

        #endregion
    }
    public class Person : INotifyPropertyChanged {
        private int Id;
        private string name;

public string Name
{
  get { return name; }
  set { name = value;
      SendPropertyChanged("Name");
  }
}
        public int ID
        {
          get { return Id; }
          set { Id = value;
          SendPropertyChanged("ID");}
        }

        #region Event Handlers

        /// <summary>
        /// This method raises the property changed event.
        /// </summary>
        /// <param name="propertyName">The property name which value has been changed</param>
        protected void SendPropertyChanged(string propertyName) {
            if (_propertyChanged != null) {
                _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler _propertyChanged;

        public event PropertyChangedEventHandler PropertyChanged {
            add {
                _propertyChanged += value;
            }
            remove {
                _propertyChanged -= value;
            }
        }

        #endregion
    }
}


Error: Put the breakpoint in setter of ActiveRecord in ViewModel. That property will never get called.

You can download the test project in the comment of this post..

http://michaelsync.net/2008/08/09/any-recommendation-for-wpf-datagrid

Note: I think that there is a wrapper for data object in your datagrid. so, I think it might be the reason why it's not working. maybe, I think I need to call DataWrapper.ActiveRecord or something...

PS: Thanks a lot for visiting my blog,  Hristo!
Atanas
Telerik team
 answered on 13 Aug 2008
4 answers
273 views
I have three-levels grouping in GridView.

I would like to specify the different style for different level for GroupRow. Is it possible to do that?

For example
-AAA (GroupRow)
-----BBB (GroupRow)
----------CCCC(Normal Row)

I want to set as below.

- Set blue color to AAA GroupRow.
- Set Yellow Color to BBB and put Textbox called TextboxLevel2 in style
- Set Pink color to CCC and put Checkbox in normal rows.

Is it possible to do that with Telerik Datagrid? Can get the value of TextboxLevel2 at runtime?


Nedyalko Nikolov
Telerik team
 answered on 13 Aug 2008
4 answers
125 views
I'm reading Styling in Expression Blend from RadGridView Doc. I found that Edit Other Templates is disabled in Blend, why?

Thanks in advance.
Chris
Telerik team
 answered on 12 Aug 2008
3 answers
275 views
Hello,

There is a feature that I never see in other chart products, for example I got 4 array of results and wants to see dynamic evolution between them.

In RadChart there is animation when it is rendered, but I mean something like a slide with my arrays and animation.
Maybe it is already there and I missed this feature.

Thanks !
Ves
Telerik team
 answered on 11 Aug 2008
9 answers
617 views
We are currently using a single grid to display data for multiple "tabs" (in reality a restyled listbox where we bind a new data source to the grid when the selected item changes).

Different tabs can have different columns displayed, so we regenerate the collection of GridViewDataColumn objects whenever tab is switched.  We always set IsCustomSortingEnabled to true on these objects.  We then hook the SortingRequested event and refetch our data whenever a column header is clicked and the collection of sorting criteria changes.  This works fine when a column header is clicked, but breaks when we switch to a tab that was previously sorted.

When we switch to a previously sorted tab, we regenerate the GridViewDataColumn collection (setting IsCustomSortingEnabled to true as ever), clear SortDescriptions on the grid and repopulate it with the correct SortDescription objects.

The problem is that setting these SortDescription's appears to trigger the RadGridView's native sorting mechanism, at which point it complains that our domain objects don't implement IComparable.  I've attached the stack trace at the end of this post.

So it looks as if somewhere in the grid code IsCustomSortingEnabled is not being checked.

All help gratefully received

Regards

Chris

-----------------

at System.Collections.Comparer.Compare(Object a, Object b)
at System.Collections.Generic.ObjectComparer`1.Compare(T x, T y)
at Telerik.Windows.Data.Grouping.NullValuesComparer`1.Compare(Object x, Object y)
at Telerik.Windows.Data.Grouping.SortDescriptionComparer`1.CompareWithIndexes(Int32 xIndex, TElement xElement, Int32 yIndex, TElement yElement)
at Telerik.Windows.Data.Grouping.SortDescriptionsComparer`1.CompareWithIndexes(Int32 xIndex, TElement xElement, Int32 yIndex, TElement yElement)
at Telerik.Windows.Data.Grouping.DataSourceIndexComparer`1.Compare(Int32 x, Int32 y)
at System.Linq.EnumerableSorter`2.CompareKeys(Int32 index1, Int32 index2)
at System.Linq.EnumerableSorter`1.QuickSort(Int32[] map, Int32 left, Int32 right)
at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Telerik.Windows.Data.Grouping.DataRecordList`1.get_UnfilteredIndexes()
at Telerik.Windows.Data.Grouping.DataRecordList`1.get_DataSourceIndexes()
at Telerik.Windows.Data.Grouping.DataRecordList`1.get_Count()
at Telerik.Windows.Data.VirtualizingRecordCollection.get_Count()
at Telerik.Windows.Data.VirtualizingRecordCollection.System.Collections.ICollection.get_Count()
at MS.Internal.Data.IndexedEnumerable.GetNativeIsEmpty(Boolean& isEmpty)
at MS.Internal.Data.IndexedEnumerable.get_IsEmpty()
at System.Windows.Data.CollectionView.get_IsEmpty()
at System.Windows.Data.CollectionView.RefreshOverride()
at System.Windows.Data.CollectionView.RefreshInternal()
at System.Windows.Data.CollectionView.RefreshOrDefer()
at System.Windows.Data.CollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at Telerik.Windows.Data.VirtualizingRecordCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Data.VirtualizingRecordCollection.OnCollectionReset()
at Telerik.Windows.Data.VirtualizingRecordCollection.Reset()
at Telerik.Windows.Data.VirtualizingRecordCollection.set_RealRecords(IList`1 value)
at Telerik.Windows.Data.RecordManager.RecalculateGroups()
at Telerik.Windows.Data.RecordManager.SortDescriptions_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedAction action, Object item, Int32 index)
at Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at Epro.ClientControls.Entity.DataGrid.EntityGridSortHandler.SetSortedColumnHeaders(ICollection`1 sortDescriptions, IEnumerable`1 propertiesToDisplay) in C:\Epro4Trunk\Epro.ClientControls\Entity\DataGrid\EntityGridSortHandler.cs:line 63
Atanas
Telerik team
 answered on 07 Aug 2008
1 answer
464 views
How can I open a second window for editing when a row in the grid is double clicked?

I have been trying to use the MouseDoubleClick event on the grid and that almost works as desired. When the event is fired I use the CurrentRecord value to determine which record needs to be shown in the new window. The problem is when someone double clicks on a part of the grid that is not a row. For example, double clicking on the header will still open the CurrentRecord even thought that record was not clicked on. I have MultipleSelect set to false so only one record can be selected at a time.
Jimmy
Telerik team
 answered on 06 Aug 2008
1 answer
490 views
Hello, I've downloaded the beta for RadCoontrols for WPF (today, 2008/8/1) and am trying to use the RadTreeView control. Looking in the .chm help file, it refers to the assembly Telerik.Windows.Controls.Navigation.dll, but I don't see that anywhere. Help!

The RadTreeView was the reason I downloaded this.

Incidentally, the opening screen when you first load the beta samples project into VS 2008, is beautiful. Where is that created, and can we get the sample source that generates this (I assume it's created in XAML somewhere?)?

Thank you for your time and help, it's great appreciated

James Hurst
Milan
Telerik team
 answered on 05 Aug 2008
7 answers
220 views
I don't know if it is just me, but the WPF Demo of the Carousel control (and only that control) crashed for almost every example I tried.  That's a little frustrating. :(  Anyway, I just wanted to alert you to that.
Allen
Top achievements
Rank 2
 answered on 04 Aug 2008
2 answers
104 views
Is it possible to prevent sorting happening when a user right clicks on a header cell? We would like to display a context menu instead, but still allow sorting if they left click.

Kind regards,

Will Holley
Will
Top achievements
Rank 1
 answered on 04 Aug 2008
1 answer
257 views

Hi,

I am building a WPF app and would like to integrate WPF treeview control from Telerik.

I have a couple of questions which will help me make decision faster.

1.Can we create dynamic context menus for different treeview nodes.
2.Can we create tree view nodes by just passing observable collection of different objects. Means like I have list of cars object at first node and then their parts as child and in second node I have Trucks or something like that.

Thanks

Atul
Valentin.Stoychev
Telerik team
 answered on 30 Jul 2008
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?