FormatException is thrown during the import of a table coming from a docx document when the application culture is "sv-SE". This happens when the column width in the document is a floating point number (ex: 120.65). The Swedish culture uses "," as decimal separator and " " as the number group separator, which makes any invariant decimal value (like 120.65) invalid during standard parsing (ex: float.Parse("120.65")).
Stacktrace:
FormatException: The input string '4514.5' was not in the correct format. at System.Single.Parse(String s) Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.TableImporter.ImportTableGrid(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Parsing.Style style) Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.TableImporter.Import(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Parsing.Style parentStyle) Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.BuildTable(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Parsing.Style parentStyle) Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.BuildBody() Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.BuildDocument() Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.Import()Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.ReadXmlContentFromPackage(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxPartImporterBase importer) Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.ReadXmlContentAndRelationsFromPackage(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxPartImporterBase importer) Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.Import() Telerik.Windows.Controls.RichTextBox.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.DocxFormatProvider.Import(System.IO.Stream input)
To work this around, switch to InvariantCulture during the import and return the original culture after that.
var cultureCache = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;
var provider= new DocxFormatProvider();
rtb.Document = provider.Import(stream);
Thread.CurrentThread.CurrentCulture = cultureCache;
Thread.CurrentThread.CurrentUICulture = cultureCache;
The fill selection stops working, after a filtering is applied and the currently selected cell is filtered out (it gets hidden). This prevents from displaying the fill selection cross displayed when you hover the bottom right corner of a selected cell. Any further changes in the selection doesn't re-enable the selection fill feature.
To work this around, you can set the IsEnabled property of the FillSelection on selection changed.
private RadWorksheetEditor activeWorksheetEditor;
public MainWindow()
{
InitializeComponent();
this.spreadsheet.ActiveSheetEditorChanged += (s, e) =>
{
if (activeWorksheetEditor != null)
{
activeWorksheetEditor.Selection.SelectionChanged -= Selection_SelectionChanged;
}
activeWorksheetEditor = this.spreadsheet.ActiveWorksheetEditor;
activeWorksheetEditor.Selection.SelectionChanged += Selection_SelectionChanged;
};
}
private void Selection_SelectionChanged(object? sender, EventArgs e)
{
this.spreadsheet.ActiveWorksheetEditor.Selection.FillSelection.IsEnabled = true;
}
Working with the RadContextMenu that comes from the RadRichTextBoxUI, when having analytics enabled, produces a NullReferenceException.
Manually set the Menu property on the PreviewMouseLeftButtonUp event of the RadMenuItem:
static MainWindow()
{
EventManager.RegisterClassHandler(typeof(RadMenuItem), PreviewMouseLeftButtonUpEvent, new MouseButtonEventHandler(OnRadMenuItemPreviewMouseLeftButtonUp), true);
}
private static void OnRadMenuItemPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
RadMenuItem radMenuItem = (RadMenuItem)sender;
RadContextMenu radContextMenu = radMenuItem.ParentOfType<RadContextMenu>();
if (radContextMenu != null)
{
PropertyInfo menuPropertyInfo = radMenuItem.GetType().GetProperty("Menu", BindingFlags.Public | BindingFlags.Instance);
if (menuPropertyInfo != null)
{
MethodInfo setMethod = menuPropertyInfo.GetSetMethod(true);
if (setMethod != null)
{
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
setMethod.Invoke(radMenuItem, new object[] { radContextMenu });
}), System.Windows.Threading.DispatcherPriority.Background);
}
}
}
}
Exception when parsing degrees. From XML:
transform: rotate(180deg);
The CollectionEditor control has a resize functionality which allows you to drag its bottom right cornet, which changes the Width and Height of the root element in the ControlTemplate of the CollectionEditor. When hosted in CollectionEditorPicker, the CollectionEditor is placed in a RadDropDownButton's DropDownContent which is basically a Popup with Placement=Bottom. When the popup goes near the bottom edge of the screen, thus doesn't having enough height to render all its contents, the Popup is automatically re-positioned so it aligns top to its parent element (the RadDropDownButton in this case). In other words, the Popup starts behaving as if its Placement=Top.
This behavior leads to issues with the vertical resizing of the CollectionEditor control. Firstly, when the Popup is automatically aligned using the Top placement, if you resize to a size small enough to fit under the picker control, the Popup gets re-positioned below the picker. Secondly, if you vertically resize the CollectionEditor to a bigger size while aligned to Top, the resizing action will increase the control height, but because of the alignment it will look like the resizing happens from the top corner of the control. In this scenario, also the buttons of the CollectionEditor disappear.
To work this around, you can disable the resizing behavior of the CollectionEditor control.
static MainWindow()
{
EventManager.RegisterClassHandler(typeof(CollectionEditor), CollectionEditor.LoadedEvent, new RoutedEventHandler(CollectionEditor_Loaded));
}
private static void CollectionEditor_Loaded(object sender, RoutedEventArgs e)
{
var collectionEditor = (CollectionEditor)sender;
var popupParent = collectionEditor.ParentOfType<Popup>();
if (popupParent != null && popupParent.PlacementTarget.GetType() == typeof(CollectionEditorPicker))
{
collectionEditor.ResizeGripperVisibility = Visibility.Collapsed;
}
}
The position of the popup representing the IntelliPrompt is wrong when shown on the monitor with the higher DPI scale, in a setup with two monitors with different DPI settings. For example, if one monitor has 100% DPI scale and the other 125%, the position of the popup will be wrong when the app is on the 125% monitor.
To work this around, use the Caret visual as the PlacementTarget for the popup and set its offsets to 0 after it is shown.
private void RadSyntaxEditor_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (KeyboardModifiers.IsControlDown && e.Key == Key.Space)
{
e.Handled = true;
var editor = (RadSyntaxEditor)sender;
CaretPosition startPosition = new CaretPosition(editor.CaretPosition);
CaretPosition endPosition = new CaretPosition(editor.CaretPosition);
editor.IntelliPrompts.CompletionListWindow.Show(startPosition, endPosition);
editor.IntelliPrompts.CompletionListWindow.HorizontalOffset = 0;
editor.IntelliPrompts.CompletionListWindow.VerticalOffset = 0;
}
}
private void RadSyntaxEditor_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
var editor = (RadSyntaxEditor)sender;
var caret = editor.FindChildByType<Telerik.Windows.Controls.SyntaxEditor.UI.Caret>();
editor.IntelliPrompts.CompletionListWindow.PlacementTarget = caret;
editor.IntelliPrompts.CompletionListWindow.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
}
ArgumentException occurs when using the voice typing feature of Windows (started with the Windows Key + H key combo) to convert speech to text in RadRichTextBox.
Exception stacktrace:
System.ArgumentException: 'Requested distance is outside the content of the associated document.'PresentationFramework.dll!System.Windows.Documents.TextPointer.TextPointer(System.Windows.Documents.TextContainer textContainer, int offset, System.Windows.Documents.LogicalDirection direction) PresentationFramework.dll!System.Windows.Documents.TextContainer.CreatePointerAtOffset(int offset, System.Windows.Documents.LogicalDirection direction) PresentationFramework.dll!System.Windows.Documents.TextParentUndoUnit.Do() PresentationFramework.dll!MS.Internal.Documents.UndoManager.Redo(int count) PresentationFramework.dll!System.Windows.Documents.TextStore.RedoQuietly(int count) PresentationFramework.dll!System.Windows.Documents.TextStore.SetFinalDocumentState(MS.Internal.Documents.UndoManager undoManager, System.Collections.Stack imeChangeStack, int appChangeCount, int imeSelectionAnchorOffset, int imeSelectionMovingOffset, int appSelectionAnchorOffset, int appSelectionMovingOffset) PresentationFramework.dll!System.Windows.Documents.TextStore.HandleCompositionEvents(int previousUndoCount) PresentationFramework.dll!System.Windows.Documents.TextStore.GrantLockWorker(MS.Win32.UnsafeNativeMethods.LockFlags flags) PresentationFramework.dll!System.Windows.Documents.TextStore.RequestLock(MS.Win32.UnsafeNativeMethods.LockFlags flags, out int hrSession)
dialog.Filter = "Special files|.*_FileNamePart.txt"Pasting an invalid range of dates in the RadDateRangePicker, for example, "ABC", raises an exception.
To work around this behavior, you could subscribe to the Loaded event of RadDateRangePicker and retrieve the DateRangeMaskedInput element via the visual tree helper methods. Then, subscribe to its ValueChanging event and check whether the NewValue property of the event arguments contains any letters or characters that are not valid. If it does, set the Handled property to True.
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.dateRangePicker.Loaded += DateRangePicker_Loaded;
}
private void DateRangePicker_Loaded(object sender, RoutedEventArgs e)
{
DateRangeMaskedInput dateRangeMaskedInput = this.dateRangePicker.FindChildByType<DateRangeMaskedInput>();
if (dateRangeMaskedInput != null)
{
dateRangeMaskedInput.ValueChanging += DateRangeMaskedInput_ValueChanging;
}
}
private void DateRangeMaskedInput_ValueChanging(object? sender, Telerik.Windows.Controls.MaskedInput.RadMaskedInputValueChangingEventArgs e)
{
if (e.NewValue.ToString().Any(char.IsLetter))
{
e.Handled = true;
}
}
}