This is a migrated thread and some comments may be shown as answers.

IsSelectionMiniToolBar doesn't show up and Toggle...() functions are freezing out.

1 Answer 47 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Tegu
Top achievements
Rank 1
Tegu asked on 20 Dec 2017, 10:35 PM

I try to enable the SelectionMiniToolbar on the RichTextBox but it doesn't show up on selected text.

When it is turned on the external formatting buttons, like B/I/U with ToggleBold/Italic/Underlined() methods are freezing out with System.NullReferenceException.

When the toolbar is not enabled everything is working well.

I think I added every references, list is attached.

Looks like the toolbar didn't initialized properly, checking the richtextbox properties it is not null, just most of it's properties. (not sure it is the expected behaviour).

 

Message:

"Object reference not set to an instance of an object."

 

Stacktrace:

   at Telerik.Windows.Controls.RichTextBoxUI.SelectionMiniToolBar.ToggleBoldCommand_ToggleStateChanged(Object sender, StylePropertyChangedEventArgs`1 e)
   at Telerik.Windows.Documents.RichTextBoxCommands.ToggleCommandBase.OnToggleStateChanged(StylePropertyChangedEventArgs`1 e)
   at Telerik.Windows.Documents.RichTextBoxCommands.ToggleCommandBase.UpdateSpanStyle()
   at Telerik.Windows.Documents.RichTextBoxCommands.RichTextBoxCommandBase.radRichTextBox_CurrentSpanStyleChanged(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at Telerik.Windows.Controls.RadRichTextBox.OnCurrentSpanStyleChanged()
   at Telerik.Windows.Controls.RadRichTextBox.CurrentSpanStyle_PropertyValueChanged(Object sender, StylePropertyChangeEventArgs args)
   at Telerik.Windows.Documents.Model.DocumentElement.OnPropertyValueChanged(IStylePropertyDefinition propertyDefinition, Object oldValue, Object newValue)
   at Telerik.Windows.Documents.Model.Styles.StyleProperty`2.OnPropertyValueChanged(TValue oldValue, TValue newValue)
   at Telerik.Windows.Documents.Model.Styles.StyleProperty`2.CheckForValueChange(RadValueSource changedValueSource)
   at Telerik.Windows.Controls.RadRichTextBox.ToggleBold()
   at HeatGun.HeatGunMainWindow.RTB_Note_BoldButton_OnClick(Object sender, RoutedEventArgs e) in D:\Visual Studio Projects\Tegu Solutions\Heat Gun\WindowHeatGunMain\HeatGunMainWindow.xaml.cs:line 243
   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 e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at Telerik.Windows.Controls.RadToggleButton.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at Telerik.Windows.Controls.RadToggleButton.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.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.RaiseTrustedEvent(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, WindowMessage 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, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   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.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at HeatGun.App.Main()

1 Answer, 1 is accepted

Sort by
0
Accepted
Boby
Telerik team
answered on 22 Dec 2017, 12:03 PM
Hello Tegu,

This exception is indication that the template of the SelectionMniToolBar is not loaded correctly, and the parts are missing (this is why you are observing that the corresponding properties are null). I can see from the screenshots that you are using the Implicit styles approach, so most probably you just have to ensure that all the needed styles are merged in the application resource dictionary, and in the proper order, e.g. your App.xaml should look like this:
<Application x:Class="Test.App"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:system="clr-namespace:System;assembly=mscorlib"
             StartupUri="MainWindow.xaml" >
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/System.Windows.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Input.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.RibbonView.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.RichTextBoxUI.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.ImageEditor.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Documents.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

Let us know if you need additional help with making this work.

Regards,
Boby
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
RichTextBox
Asked by
Tegu
Top achievements
Rank 1
Answers by
Boby
Telerik team
Share this question
or