Telerik Forums
UI for WPF Forum
2 answers
189 views
This code used to work with an older Telerik release (can verify the version if need be), but no longer works with the latest (RadControls_for_WPF_2012_1_0215_Dev).

Steps to reproduce:
1. Right-click and select the context menu item to add a top-level row.
2. Right-click the row and select the context menu item to add a child row.
3. Right-click the child row, and you get the exception.

TreeListViewRow.ParentRow throws an exception because it tries to do "var parentView = this.Items.ParentView;" but Items is null.

Each top-level (parent) row contains a ParentItem object with a ChildItems property, and the ChildTableDefinition is bound to the ChildItems property. Each child row contains a ChildItem object, which doesn't have a ChildItems property, so when it tries to get the child items for a child row, the collection is null. As a workaround, if I give the ChildItem class a ChildItems property and have it return an empty collection, then the exception goes away. I'm no telerik expert, but it seems strange to me that a row needs to have a non-null collection of child items in order to access the row's parent row.

Apparently you don't let users upload test projects, so here's the source:

MainWindow.xaml:
<Window x:Class="TestTreeListView.MainWindow"
        xmlns:local="clr-namespace:TestTreeListView"
        xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
         
        Name="mainWindow"
        Title="MainWindow"
        Height="350"
        Width="525">
    
   <Window.CommandBindings>
      <CommandBinding Command="local:MainWindow.AddParentRow" Executed="AddParentRow_Executed" />
   </Window.CommandBindings>
    
   <Window.Resources>
 
      <!-- The style of the expand button in the totally rad tree. -->
      <Style x:Key="ExpandButtonStyle" TargetType="{x:Type telerik:GridViewToggleButton}">
         <Setter Property="PresentationMode" Value="PlusMinus"/>
      </Style>
 
      <!-- Context menu for adding a child row to a parent row. -->
      <ContextMenu x:Key="ParentRowContextMenu">
         <ContextMenu.CommandBindings>
            <CommandBinding Command="local:MainWindow.AddChildRow" Executed="AddChildRow_Executed" />
         </ContextMenu.CommandBindings>
         <MenuItem Command="local:MainWindow.AddChildRow" />
      </ContextMenu>
 
      <!-- A sorted view of the totally rad tree items. -->
      <CollectionViewSource x:Key="TotallyRadItemsView"
                            Source="{Binding ElementName=mainWindow, Path=ParentItems}">
         <CollectionViewSource.SortDescriptions>
            <scm:SortDescription PropertyName="Name" />
         </CollectionViewSource.SortDescriptions>
      </CollectionViewSource>
 
   </Window.Resources>
    
   <Grid>
      <telerik:RadTreeListView Name="totallyRadTreeListView"
                               AutoGenerateColumns="True"
                               GridLinesVisibility="None"
                               RowIndicatorVisibility="Collapsed"
                               IsFilteringAllowed="False"
                               CanUserSortColumns="False"
                               HierarchyExpandButtonStyle="{StaticResource ExpandButtonStyle}"
                               ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                               ItemsSource="{Binding Source={StaticResource TotallyRadItemsView}}">
 
         <telerik:RadTreeListView.ChildTableDefinitions>
            <telerik:TreeListViewTableDefinition ItemsSource="{Binding ChildItems}" />
         </telerik:RadTreeListView.ChildTableDefinitions>
 
         <telerik:RadTreeListView.ContextMenu>
            <!-- Context menu for adding a parent row. -->
            <ContextMenu>
               <MenuItem Command="local:MainWindow.AddParentRow"
                         CommandTarget="{Binding Path=PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}" />
            </ContextMenu>
         </telerik:RadTreeListView.ContextMenu>
      </telerik:RadTreeListView>
   </Grid>
</Window>

MainWindow.xaml.cs:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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 Telerik.Windows.Controls.GridView;     // for RowLoadedEventArgs
using Telerik.Windows.Controls.TreeListView; // for TreeListViewRow
 
namespace TestTreeListView
{
   /// <summary>
   /// Interaction logic for MainWindow.xaml
   /// </summary>
   public partial class MainWindow : Window
   {
      public MainWindow()
      {
         InitializeComponent();
 
         // RadTreeListView doesn't select its items on right-click, so add
         // an event handler that accomplishes this.
         mTreeItemClickHandler = new MouseButtonEventHandler( TotallyRadTreeListViewRow_MouseRightButtonDown );
         totallyRadTreeListView.RowLoaded += new EventHandler<RowLoadedEventArgs>( TotallyRadTreeListView_RowLoaded );
         totallyRadTreeListView.RowUnloaded += new EventHandler<RowUnloadedEventArgs>( TotallyRadTreeListView_RowUnloaded );
      }
 
      static MainWindow()
      {
         AddParentRow = new RoutedUICommand( "Add Parent Row", "AddParentRow", typeof( MainWindow ) );
         AddChildRow = new RoutedUICommand( "Add Child Row", "AddChildRow", typeof( MainWindow ) );
      }
 
      public static RoutedUICommand AddParentRow { get; set; }
      public static RoutedUICommand AddChildRow { get; set; }
 
      public ObservableCollection<ParentItem> ParentItems { get { return mParentItems; } }
 
      private void TotallyRadTreeListViewRow_MouseRightButtonDown( object sender, MouseButtonEventArgs e )
      {
         TreeListViewRow row = sender as TreeListViewRow;
         row.IsSelected = true;
 
         // Throws an exception when right-clicking a child row.
         if ( row.ParentRow != null )
         {
            // use row.ParentRow.Item here
         }
 
         // Show the context menu whenever a parent row is clicked.
         if ( row.Item is ParentItem )
         {
            ContextMenu menu = FindResource( "ParentRowContextMenu" ) as ContextMenu;
            menu.IsOpen = true;
         }
      }
 
      private void TotallyRadTreeListView_RowLoaded( object sender, RowLoadedEventArgs e )
      {
         if ( e.Row.Item != null )
         {
            e.Row.MouseRightButtonDown += mTreeItemClickHandler;
         }
      }
 
      private void TotallyRadTreeListView_RowUnloaded( object sender, RowUnloadedEventArgs e )
      {
         e.Row.MouseRightButtonDown -= mTreeItemClickHandler;
      }
 
      private void AddParentRow_Executed( object target, ExecutedRoutedEventArgs e )
      {
         mParentItems.Add( new ParentItem() );
      }
 
      private void AddChildRow_Executed( object target, ExecutedRoutedEventArgs e )
      {
         ParentItem parentItem = totallyRadTreeListView.SelectedItem as ParentItem;
         parentItem.ChildItems.Add( new ChildItem() );
      }
 
      private MouseButtonEventHandler mTreeItemClickHandler = null;
      ObservableCollection<ParentItem> mParentItems = new ObservableCollection<ParentItem>();
   }
 
   public class ParentItem
   {
      public string Name { get { return name; } }
      public ObservableCollection<ChildItem> ChildItems { get { return mChildItems; } }
       
      private string name = "Parent" + i++;
      ObservableCollection<ChildItem> mChildItems = new ObservableCollection<ChildItem>();
 
      private static int i = 0;
   }
 
   public class ChildItem
   {
      public string Name { get { return name; } }
      //public ObservableCollection<ChildItem> ChildItems { get { return mChildItems; } }
 
      private string name = "Child" + i++;
      //ObservableCollection<ChildItem> mChildItems = new ObservableCollection<ChildItem>();
 
      private static int i = 0;
   }
}
Cale
Top achievements
Rank 1
 answered on 01 Mar 2012
4 answers
246 views
Hi,

I'm using Telerik V2011.3.1220.35 and I have a problem with my RadWindow when I set his WindowState property to Maximized.

When I set the WIndowState property to Maximized in my XAML, when my application start, my RadWindow is Maximized and it override my taskbar. 

If I remove the WindowState="Maximized" from my XAML and I set it in the OnLoaded event of my RadWIndow, my RadWindow become Maximized without hidding my taskbar.

In both situations, if I change the AutoHide porperty of my taskbar to TRUE, when my RadWindow become Maximized, I cannot get my taskbar visible just by moving my mouse at the bottom of my screen.

Thank's
Oliver
Top achievements
Rank 1
 answered on 01 Mar 2012
1 answer
97 views
When I put in NumericUpDown minimum value, and I click down button then value of binding variable becomes less then minimum, but control shows right value.
I used this code for initialize in xaml:
<telerik:RadNumericUpDown Name="TopNSpinner" IsEditable="True" Minimum="1" ValueFormat="Numeric"
Value="{Binding Result.TopNEventsCount, Mode=TwoWay}"/>

And this code for initializing in C#:

TopNSpinner.NumberFormatInfo = new NumberFormatInfo() { NumberDecimalDigits = 0 };

So, if I have value is 1 in control, then i can get 0 in variable, but control will show 1.
Please help.
Rosi
Telerik team
 answered on 01 Mar 2012
2 answers
191 views
Dear Telerik Team,

i have a little quest.

I Have a RadScheduleView Control, with an AppointmentDatasource, which get's the Appointments from
a Webservice.

My Problem is, that the Appointments will be loaded by to Webservice calls

Step 1. FreeBusyAppointments
Step 2. ExchangeAppointment Details

Step 1 work very well and very fast, but Step 2. needs a lot of time, because the Backendservers are very slow while fetching the data.

So my solutions ist, that i turn on a busy indicator, loading Step 1 from the Webservice, put the Appointments into the RadschedulerView,
then turn off the busy inidcator and start a backgroundworker which loads the ExchangeAppointment details. When Step 2 is finished
the Appointments will be added to the Rad Scheduleview.

This should give users the possibility to see and user the radscheduleview before all appointment details are loaded.

That's the plan.

The Problem is, that after i turn of the busy indicator and starting the backgroundworker,
i see the freebusy appointments in the radscheduleview, but the busy indicator is also stil shown,
but it hangs up (including the InternetExplorer) until all Appointments from step 2 are loaded and filled into the radscheduleview.

I can easily reproduce this with filling some static Appointments in the RadScheduleview while blocking the Backgroundworker process with a 

System.Threading.Thread.Sleep(xxxx);


Is there any Solution about such a scenario - because the Step 2. can take up to 30 seconds, and the control is unusable during this period

thanks for your help

kind regards
Rudi
Rudolf
Top achievements
Rank 1
 answered on 01 Mar 2012
4 answers
147 views
Hi,

I have problems to use print-method in RadRichTextBox control. E.g when I dynamically load RadRichTextBox to the visual tree and then set the document. This throws an null exception when I call the Print-method.

RadRichTextBox textBox = new RadRichTextBox();
grid.Children.Add(textBox);
textBox.ApplyTemplate();
textBox.UpdateEditorLayout();
textBox.Document = this.CreateDocument();
textBox.Print("MyDoc", PrintMode.Native);  // It crash in here!

CreateDocument returns a valid document, I have tested it by loading it to radRichtextbox without printing.

Hopefully you can see directly what is wrong in my code... if you can provide sample project, that would also help.

 I'm using WPF version of Telerik controls (ver. 2011.2.712.40)

Regards,
Auvo



Iva Toteva
Telerik team
 answered on 01 Mar 2012
1 answer
157 views
Hi,

We want to remove certain words from the dictionary (any words that would be embarrassing for customers...  including some that may be proper anatomy words, but wouldn't be used in our application).  Is the best way to do this to download the dictionary from  http://www.telerik.com/community/forums/aspnet-ajax/spell/147971-radspell-dictionaries.aspx#576503, and edit the dictionary?  If not, what is the best way to go about that?

If we are going to edit the dictionary, can we add our own custom words directly to it rather than creating an IWordCustomDictionary?  If that's okay, what do the last two items on a line in a TDF file represent?  For example, what do the JNNL and KNNL represent in the following line:

genuinely:JNNL:KNNL

Thanks!
Ivailo Karamanolev
Telerik team
 answered on 01 Mar 2012
5 answers
155 views
I'm following the GridView demo called "Search as you type". I am using the exact code from the example (CustomFilterBehavior.cs and CustomFilterDescriptor.cs). I have found that the filter does not work if your data has a column of doubles all with a value of 0. If the doubles are given values > 0 then suddenly the filtering works but at 0 no filtering is applied. Very odd.

Can you verify this problem and suggest a work around, possibly a change to CustomFilterDescriptor.cs?

thanks.
Maya
Telerik team
 answered on 01 Mar 2012
4 answers
208 views
Hi,

We are using WPF RadGridview control inside the RadExpander. We like to know how to display the RadGridview's selected (only one) row  in the header section of the RadExpander while collpsing it.

Please refer the attached image for clear understanding of our need.

It would be great if you could provide us the sample project in WPF.

Thanks.
Maya
Telerik team
 answered on 01 Mar 2012
3 answers
93 views
I'm working with a gridview that has a CellTemplate with a CheckBox column and I'm able to set the IsEnabled value using the following code.

    IList<CheckBox> cbks = myGridView.ChildrenOfType<CheckBox>().ToList<CheckBox>();
    MyObject selectedProject = myGridView.SelectedItem as MyObject;
    int SelectedIndex = myGridView.Items.IndexOf(selectedProject);
    cbks[SelectedIndex].IsEnabled = True;
 

This works great, but except ChildrenOfType<>() only provides the rows for visible rows. I can not set EnableRowVirtualization to False.



How do I get the index of the visible row that is within the List of checkboxes (chks)?


Thanks in advance.
Maya
Telerik team
 answered on 01 Mar 2012
3 answers
185 views
For the sake of the others, please update your custom sorting guide to include IsCustomSortingEnabled on the columns. I spent almost a day figuring out why the sorting didn't work anymore (It sorts once but the NewSortingState property doesn't stick). This is very frustrating and is nowhere mentioned as a requirement.
Vlad
Telerik team
 answered on 01 Mar 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?