RadComboBox.IsDropDownOpenProperty problem

2 posts, 1 answers
  1. Massimiliano Giustizieri
    Massimiliano Giustizieri avatar
    18 posts
    Member since:
    Oct 2009

    Posted 15 Oct 2009 Link to this post

    Dear team,

    I have a problem when setting the IsDropDownOpenProperty on a RadComboBox, Yes, I know there's a similar post (that I've read) but that did not help me to solve my problem. ;)
    I have a RadGridView, where the CellEditTemplate of a given column must change at runtime, depending on the type of row that is currently being edited.
    So I have an event handler at the RadGridView SelectionChanged event, that determines the type of row (meaning the type of data we have inside it), and then dinamically builds a DataTemplate that is assigned to the grid column.
    In one particular case, this template is a RadComboBox with a set of available values, and the core instructions that build this template are the followings:

    FrameworkElementFactory radComboFactory = new FrameworkElementFactory ( typeof ( RadComboBox ), "RadComboFactory" ); 
    radComboFactory.SetValue ( RadComboBox.ItemsSourceProperty, property.AvailableValues ); 
    radComboFactory.SetValue ( RadComboBox.SelectedValuePathProperty, "Key" ); 
    radComboFactory.SetValue ( RadComboBox.SelectedValueProperty, currentValue ); 
    radComboFactory.SetValue ( RadComboBox.IsDropDownOpenProperty, true ); 
    radComboFactory.SetValue ( CSRadComboSelectionChanged.CommandProperty, CellEditTemplateComboSelectionChange ); 
    propertyDataTemplate.VisualTree = radComboFactory; 
    propertyDataTemplate.Seal ( ); 

    Everything worked fine, until I introduced the 4th dependecy property, which is RadComboBox.IsDropDownOpenProperty because I clearly wanted the combo box to be displayed already opened.
    The template is built correctly, but this gives me an error when it is going to be instantiated into my RadGridView's column.
    The exception details are:
    System.NullReferenceException was unhandled
      Message="Object reference not set to an instance of an object."
      Source="Telerik.Windows.Controls.Input"
      StackTrace:
       at Telerik.Windows.Controls.RadComboBox.OnIsDropDownOpenChanged(Boolean oldValue, Boolean newValue) 
       at Telerik.Windows.Controls.RadComboBox.OnIsDropDownOpenChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) 
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) 
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) 
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) 
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType) 
       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal) 
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) 
       at System.Windows.FrameworkTemplate.SetTemplateParentValues(String name, Object element, FrameworkTemplate frameworkTemplate, ProvideValueServiceProvider& provideValueServiceProvider) 
       at System.Windows.FrameworkElementFactory.InstantiateUnoptimizedTree() 
       at System.Windows.FrameworkTemplate.LoadContent() 
       at Telerik.Windows.Controls.GridViewColumn.CreateCellEditElement(GridViewCell cell, Object dataItem) 
       at Telerik.Windows.Controls.GridView.GridViewCell.SetEditorContent(Object content) 
       at Telerik.Windows.Controls.GridView.GridViewCell.ShowEditor() 
       at Telerik.Windows.Controls.GridView.GridViewCell.<ToggleEditor>b__0() 
       at Telerik.Windows.Controls.GridView.GridViewCell.ModifyCellTemplate(Action executeAction) 
       at Telerik.Windows.Controls.GridView.GridViewCell.ToggleEditor() 
       at Telerik.Windows.Controls.GridView.EditContext.OnCellEditModeChanged(GridViewCell cell, Boolean newIsInEditMode) 
       at Telerik.Windows.Controls.GridView.GridViewCell.IsInEditModeChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) 
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) 
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) 
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) 
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType) 
       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal) 
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) 
       at Telerik.Windows.Controls.GridView.GridViewCell.set_IsInEditMode(Boolean value) 
       at Telerik.Windows.Controls.GridView.EditContext.SwitchCellToEditMode(GridViewCell cell) 
       at Telerik.Windows.Controls.GridView.EditContext.BeginEdit(GridViewCell gridViewCell) 
       at Telerik.Windows.Controls.GridView.EditContext.OnCellMouseUp(GridViewCell cell) 
       at Telerik.Windows.Controls.GridView.GridViewCell.OnMouseLeftButtonUp(MouseButtonEventArgs e) 
       at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e) 
       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) 
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) 
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
       at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) 
       at System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject sender, MouseButtonEventArgs e) 
       at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e) 
       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) 
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) 
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) 
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) 
       at System.Windows.Input.InputManager.ProcessStagingArea() 
       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) 
       at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) 
       at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) 
       at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
       at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) 
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) 
       at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) 
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) 
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) 
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) 
       at System.Windows.Threading.Dispatcher.Run() 
       at System.Windows.Application.RunDispatcher(Object ignore) 
       at System.Windows.Application.RunInternal(Window window) 
       at System.Windows.Application.Run(Window window) 
       at System.Windows.Application.Run() 
       at ***********.Shell.App.Main() in *****************************************************************\obj\Debug\App.g.cs:line 0 
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) 
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
       at System.Threading.ThreadHelper.ThreadStart() 

     (a bit long, sorry ... )

    If I comment out the faulty line, the DataTemplate is instantiated correctly, and I can see my combo box in the RadGridView, but it is obviously closed, which is not fine for my case.
    I also tried a similar, parallel case, where I replaced the RadComboBox with standard Windows WPF ComboBox, and I was surprised that I can use the ComboBox.IsDropDownOpenProperty without any problem, and the ComboBox that is built, is shown already opened just like I wanted it to be.

    I would be happy to use a workaround also, to fix this.

    Thanks a lot for your effort and do not hesitate to ask me any further information that may help you.

    Kind Regards.

    Max.
  2. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 21 Oct 2009 Link to this post

    Hello Max,

    I apologize for the delayed reply. I managed to reproduce and fix the problem. The fix will be available in the Q3 2009 release, scheduled for the first week of November.

    I updated your points.

    Best wishes,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top