Telerik Forums
UI for WPF Forum
3 answers
171 views
I'm having issues trying to bind IsExpanded to a bool property

<telerik:RadTreeListView.RowStyle>
    <Style TargetType="{x:Type telerik:TreeListViewRow}">
        <!--<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />-->
        <Setter Property="IsExpanded" Value="True" />
    </Style>
</telerik:RadTreeListView.RowStyle>

First I tried using first setter but I would get exceptions.
Then I tried to bind to the second to isolate the issue. This is the exception I get:


Message:
Object reference not set to an instance of an object.

Stack:
   at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.OnItemAdded(Object item, Int32 index) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\ItemsControl\GridViewItemContainerGenerator.cs:line 2442
   at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\ItemsControl\GridViewItemContainerGenerator.cs:line 2411
   at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\ItemsControl\GridViewItemContainerGenerator.cs:line 2290
   at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\DataItemCollection.cs:line 665
   at Telerik.Windows.Data.DataItemCollection.OnCollectionViewCollectionChanged(NotifyCollectionChangedEventArgs e) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\DataItemCollection.cs:line 642
   at Telerik.Windows.Data.DataItemCollection.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs e) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\DataItemCollection.cs:line 1046
   at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\WeakEvents\WeakEvent.cs:line 33
   at Telerik.Windows.Data.QueryableCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 677
   at Telerik.Windows.Data.QueryableCollectionView.ProcessSynchronousCollectionChangedWithAdjustedArgs(NotifyCollectionChangedEventArgs originalArguments, Int32 adjustedOldIndex, Int32 adjustedNewIndex) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1133
   at Telerik.Windows.Data.QueryableCollectionView.ProcessSynchronousCollectionChanged(NotifyCollectionChangedEventArgs args) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1053
   at Telerik.Windows.Data.QueryableCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 983
   at Telerik.Windows.Data.HierarchicalCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\HierarchicalCollectionView.cs:line 249
   at Telerik.Windows.Data.QueryableCollectionView.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1343
   at Telerik.Windows.Data.QueryableCollectionView.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1328
   at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\WeakEvents\WeakEvent.cs:line 33
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
   at System.Collections.ObjectModel.Collection`1.Add(T item)

The exception occurs when I'm adding a new item to the IEnumerable source that the RadTreeListView is bound to. It is bound to an observable collection (And the bottom 4 lines of the stack are from the Observable collection)




Is there a better way of binding to the IsExpanded property?

v.2011.1.315.35
Vlad
Telerik team
 answered on 09 Aug 2011
0 answers
139 views
Hello,
I want to copy multiple rows from excel and paste them to my grid. At my first copy action all off the rows are copied. but when i try to copy other rows, blank cells-rows are pasted to the grid. i have checked Clipboard.GetText(); but it is not empty.
I have a grid like below
<telerik:RadGridView AutoGenerateColumns="False" Margin="5" ShowGroupPanel="False" HorizontalAlignment="Left"
                             Name="DataGridProducts" IsFilteringAllowed="False" ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
                             AncestorType={x:Type local:PageUpdateProductMainFields}},Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Path=Products}"
                             Pasting="DataGridProducts_Pasting" KeyDown="DataGridProducts_KeyDown">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="Malzeme Kodu"  DataMemberBinding="{Binding ItemStockCode}" Width="150"/>
                <telerik:GridViewDataColumn Header="Malzeme Adı" DataMemberBinding="{Binding ItemName}" Width="150"/>
                <telerik:GridViewDataColumn Header="Alış Fiyatı"  DataMemberBinding="{Binding IncomePrice}" Width="100"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

the items source and the events in the grid is below
private DynaList<Product> _Products;
public DynaList<Product> Products
{
    get
    {
        if (_Products == null)
            _Products = new DynaList<Product>();
        return _Products;
    }
    set
    {
        _Products = value;
    }
}
public void AddEmptyProduct()
{
    Product tempProduct = new Product();
    Products.Insert(Products.Count, tempProduct);
}
 
private void DataGridProducts_Pasting(object sender, Telerik.Windows.Controls.GridViewClipboardEventArgs e)
{
    string nodes1 = Clipboard.GetText();
    string[] nodes2 = nodes1.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
    for (int i = 1; i < nodes2.Count(); i += 1)
    {
        AddEmptyProduct();
    }
}
 
private void DataGridProducts_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
    if (e.Key == Key.RightShift)
    {
        DataGridProducts.CommitEdit();
        AddEmptyProduct();        
        DataGridProducts.SelectedItem = DataGridProducts.Items[Products.Count - 1];
    }
}

Ahmet Özgür
Top achievements
Rank 1
 asked on 09 Aug 2011
1 answer
114 views
Hello,

just moved from R1 to R2 and we have a problem with some of the bindings in the GridView
In the UC I have a grid described like this:
<telerik:RadGridView
                            Margin="6,6,1,4"
                            CanUserReorderColumns="False"
                            CanUserDeleteRows="False"
                            CanUserInsertRows="False"
                            IsReadOnly="True"
                            AutoGenerateColumns="False"
                            IsFilteringAllowed="False"
                            SelectionMode="Extended"
                            SelectedItem="{Binding PersoanaSelectata, Mode=TwoWay}"
                            ItemsSource="{Binding Persoane, Mode=TwoWay}"
                            Name="radGridViewPersoane"
                            ShowGroupPanel="False" >
                   <telerik:RadGridView.Columns>
                       <telerik:GridViewDataColumn Header="Nume"
                                           DataMemberBinding="{Binding Nume}"  Width="4*" TextWrapping="Wrap" IsReadOnly="True"/>
                       <telerik:GridViewDataColumn Header="Prenume"
                                           DataMemberBinding="{Binding Prenume}" Width="4*" TextWrapping="Wrap" IsReadOnly="True"/>
                       
                   </telerik:RadGridView.Columns>
               </telerik:RadGridView>

in the vm I have the properties

private VerificarePersoana _verificarePersoana;
        public VerificarePersoana VerificarePersoana
        {
            get
            {
                if (_verificarePersoana == null)
                    _verificarePersoana = new VerificarePersoana();
                return _verificarePersoana;
            }
            set
            {
                _verificarePersoana = value;
                Notify("VerificarePersoana");
            }
        }
 
        private ObservableCollection<Persoana> persoane;
        public ObservableCollection<Persoanaa> Persoane
        {
            get
            {
                if (_verificarePersoana.Persoane == null)
                {
                    _verificarePersoana.Persoane = new ObservableCollection<Persoana>();
                    
                }
                return _verificarePersoana.Persoane;
            }
            set
            {
                _verificarePersoana.Persoane = value;
                Notify("Persoane");
            }
        }



and in  persoana I have something like
private string _nume;
public string Nume
{
    get { return _nume; }
    set { _nume = value; Notify("Nume"); }
}
 
private string _prenume;
public string Prenume { get { return _prenume; } set { _prenume=value; Notify("Prenume"); } }

  public void Notify(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }


My problem is that in R1 when I updated the information in a separate form for one of the entries the information got updated in the grid too. now it doesn't do that. If i sort the items by a column the information shows up correctly again.

Why is that? i would really like to move my solution to R2 but this is really a problem.

Thanks in advance.
Vlad
Telerik team
 answered on 09 Aug 2011
1 answer
87 views
I have a RadGridView with a default sort descriptor defined in xaml for my grid.
Wen i run the project, if i press return two times, an exception is trown.

Application: WpfApplication3.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
Stack:
   at System.Collections.Generic.ArraySortHelper`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].BinarySearch(System.__Canon[], Int32, Int32, System.__Canon, System.Collections.Generic.IComparer`1<System.__Canon>)
   at System.Array.BinarySearch[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.__Canon[], Int32, Int32, System.__Canon, System.Collections.Generic.IComparer`1<System.__Canon>)
   at System.Collections.Generic.List`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].BinarySearch(Int32, Int32, System.__Canon, System.Collections.Generic.IComparer`1<System.__Canon>)
   at Telerik.Windows.Data.KeyedCollection.IndexOf(System.Object)
   at Telerik.Windows.Data.QueryableCollectionView.InternalIndexOf(System.Object)
   at Telerik.Windows.Data.QueryableCollectionView.IndexOf(System.Object)
   at Telerik.Windows.Data.QueryableCollectionView.Contains(System.Object)
   at Telerik.Windows.Data.DataItemCollection.Contains(System.Object)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CanActivateRowExecute(System.Object, System.Windows.Input.CanExecuteRoutedEventArgs)
   at System.Windows.Input.CommandBinding.OnCanExecute(System.Object, System.Windows.Input.CanExecuteRoutedEventArgs)
   at System.Windows.Input.CommandManager.FindCommandBinding(System.Windows.Input.CommandBindingCollection, System.Object, System.Windows.RoutedEventArgs, System.Windows.Input.ICommand, Boolean)
   at System.Windows.Input.CommandManager.FindCommandBinding(System.Object, System.Windows.RoutedEventArgs, System.Windows.Input.ICommand, Boolean)
   at System.Windows.Input.CommandManager.OnCanExecute(System.Object, System.Windows.Input.CanExecuteRoutedEventArgs)
   at System.Windows.UIElement.OnCanExecuteThunk(System.Object, System.Windows.Input.CanExecuteRoutedEventArgs)
   at System.Windows.Input.CanExecuteRoutedEventArgs.InvokeEventHandler(System.Delegate, System.Object)
   at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
   at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
   at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs, Boolean)
   at System.Windows.Input.RoutedCommand.CriticalCanExecuteWrapper(System.Object, System.Windows.IInputElement, Boolean, System.Windows.Input.CanExecuteRoutedEventArgs)
   at System.Windows.Input.RoutedCommand.CanExecuteImpl(System.Object, System.Windows.IInputElement, Boolean, Boolean ByRef)
   at System.Windows.Input.RoutedCommand.CriticalCanExecute(System.Object, System.Windows.IInputElement, Boolean, Boolean ByRef)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.ExecutePendingCommand()
   at Telerik.Windows.Controls.GridView.GridViewDataControl.OnKeyDown(System.Windows.Input.KeyEventArgs)
   at System.Windows.UIElement.OnKeyDownThunk(System.Object, System.Windows.Input.KeyEventArgs)
   at System.Windows.Input.KeyEventArgs.InvokeEventHandler(System.Delegate, System.Object)
   at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
   at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
   at System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs)
   at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs, Boolean)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs)
   at System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport)
   at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr, System.Windows.Input.InputMode, Int32, System.Windows.Input.RawKeyboardActions, Int32, Boolean, Boolean, Int32)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(System.Windows.Interop.MSG ByRef, Boolean ByRef)
   at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(System.Windows.Interop.MSG ByRef, System.Windows.Input.ModifierKeys)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at System.Windows.Threading.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority, System.Delegate, System.Object)
   at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(System.Windows.Interop.MSG ByRef, Boolean ByRef)
   at System.Windows.Interop.HwndSource+WeakEventPreprocessMessage.OnPreprocessMessage(System.Windows.Interop.MSG ByRef, Boolean ByRef)
   at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(System.Object)
   at System.Windows.Application.RunInternal(System.Windows.Window)
   at System.Windows.Application.Run(System.Windows.Window)
   at System.Windows.Application.Run()
   at WpfApplication3.App.Main()



the folowing code, reproduces my issue.

<Window x:Class="WpfApplication3.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
<telerik:RadGridView x:Name="grid" ItemsSource="{Binding Itens}">
    <telerik:RadGridView.SortDescriptors>
        <telerik:SortDescriptor Member="Id" SortDirection="Ascending" />
    </telerik:RadGridView.SortDescriptors>
</telerik:RadGridView>
    </Grid>
</Window>

public class Item
{
    public int Id { get; set; }
    public string Name { get; set; }
}
 
public class ViewModel
{
    public ObservableCollection<Item> Itens { get; set; }
 
    public ViewModel()
    {
        this.Itens = new ObservableCollection<Item>();
 
        Itens.Add(new Item() { Name = "teste", Id = 0 });
        Itens.Add(new Item() { Name = "teste 1", Id = 1 });
        Itens.Add(new Item() { Name = "teste 2", Id = 2 });
    }
}
 
public partial class MainWindow : Window
{
    public MainWindow()
    {
        this.DataContext = new ViewModel();
        InitializeComponent();
    }
}
Yordanka
Telerik team
 answered on 09 Aug 2011
2 answers
126 views
User would like to be avoid stopping at a date since it isn't always required.  Setting the IsTabStop to False doesn't work.  Even after setting the IsTabStop property to false, the cursor continues to stop for each part of the date (mm/dd/yyyy).
Bhavesh
Top achievements
Rank 1
 answered on 08 Aug 2011
2 answers
153 views
hi there,

I'm fairly new to Telerik and WPF so I was wondering if someone could help me with a few questions.
My questions are related mainly to RadScheduleView Drag and Drop behavior and also the ability to show a RadContextMenu in a specific area of the radscheduleview control. I have included a sample project and the screenshot below.

1. If I drag a GridViewRow to a schedule view, is it possible to delete that row from my grid after it is dragged to the RadScheduleView ?
2. Is it possible to drag a GridViewRow and drag that row to the GroupHeader and then add a new resource ?
How can I do that?
3. Why does my custom ScheduleViewDragDropBehavior keep calling ConvertDraggedData
even if DragComplete is not actually reached in the OnDragInfo draghandler of my RadGridView ?
4. How can I setup my RadContextMenu to only show up in the GroupHeader to the left (I'm using Timeline View)?
Is it possible to hide ContextMenu when I right click the TimeViewDefinition area ?

SampleProject
AppScreenshot
Elneilo
Top achievements
Rank 1
 answered on 08 Aug 2011
2 answers
111 views
Looking for input on what others do. I've implemented a custom provider. I create a large image in memory and then slice it into tiles. This works until the image is too big and I run out of memory. Surely there is a better way to do this. Ideally I would like something that creates the tiles directly to disk. Another 'problem' is that I'm doing things like 'DrawPolygon' onto my image so I don't have knowledge of exactly which pixels are being colored, otherwise I could easily figure which pixels to write to. Appreciate any help. Thanks.
Jason D
Top achievements
Rank 1
Veteran
 answered on 08 Aug 2011
2 answers
128 views
I want to bind a chart to a table in sql server, is that possible in wpf for windows application?

Thanks in advance
Evgenia
Telerik team
 answered on 08 Aug 2011
1 answer
108 views
When the user adds a new row to the GridView and then cancels the inserting process the event 'RowEditEnded' is called with "e.EditOperationType == Insert" and  "e.EditAction == Cancel".

Is there some way to get the BusinessObject behind the inserted row that was canceled?

e.EditedItem, e.NewData are both null.
Ivan Ivanov
Telerik team
 answered on 08 Aug 2011
7 answers
179 views
Hi,
I am trying to bind a hierachical gridview using entity framework 4.0. (tables: Countries with Districts)
Whenever i try to add a child table definition to the main gridview  the ability to sort the child gridview is lost ( when setting the property relation):
d.Relation = new Telerik.Windows.Data.PropertyRelation("Districts");

If i manually add the datasource then sorting works perfectly. Is this the normal behaviour ? Am i doing something wrong?

GridViewTableDefinition d = new GridViewTableDefinition();
d.DataSource = new SofERPEntities().Districts.Where(z=>z.CountryId==5).ToList();   => sorting in child gridview works
 //d.Relation = new Telerik.Windows.Data.PropertyRelation("Districts");  => sorting in child gridview not working
this.radGridView1.ChildTableDefinitions.Add(d);


Dimitrina
Telerik team
 answered on 08 Aug 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?