StackTrace:
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Telerik.WinControls.VisualElement.GetScaledFont(Single scale)
at Telerik.WinControls.UI.LightVisualElement.CreateTextParams()
at Telerik.WinControls.UI.GridCellElement.CreateTextParams()
at Telerik.WinControls.UI.TextPart.Measure(SizeF availableSize)
KeyNotFoundException when trying to access a dictionary in GetScaledFont, because of race condition, when setting a Font in another thread.
When a RadSvgImage document is modified the cache of raster images needs to be cleared, so the modifications can be visualized.
For example we want to change the following SVG
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs>
<style>.cls-1{fill:none;stroke:#228bcb;stroke-miterlimit:5;stroke-width:1.2px;} </style>
</defs>
<g id="undoModern16">
<g id="icon">
<path class="cls-1" d="M5.61,10.36.82,5.51,5.61.63M9.5,14.5h1.28A4.51,4.51,0,0,0,15.38,10h0a4.52,4.52,0,0,0-4.6-4.5H.82" />
</g>
</g>
</svg>
Here is how it looks :
To change the color of this SVG we need to change the stroke color of the path that represents the arrow. First, we need to find the element of type SvgPath and then set its stroke to the desired color.
RadSvgImage svg = this.buttonUndo.SvgImage;
Svg.SvgPath path = svg.Document.Children.FindSvgElementOf<Svg.SvgPath>();
// set arrow color to gray(51,51,51)
path.Stroke = new Svg.SvgColourServer(System.Drawing.Color.FromArgb(51, 51, 51));
// no API to reset the cache
As a workaround we need to reassign the image of button:
// clear the cache of RadSvgImage
this.buttonUndo.SvgImage = null;
this.buttonUndo.SvgImage = svg;
Another possible workaround when working with LightVisualElement and its derivatives is to clear the cache with reflection:
var fi = svg.GetType().GetField("cachedSizesToImages", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
fi.SetValue(svg, new Dictionary<Size, Bitmap>());
workaround: public class MyGridView : RadGridView { public override string ThemeClassName { get { return typeof(RadGridView).FullName; } } protected override void ProcessCodedUIMessage(ref IPCMessage request) { if (request != null) //here is the problematic point base.ProcessCodedUIMessage(ref request); } }
After revamping the documentation for the Telerik UI for WinForms product, the following problems occurred: 1. Search for a specific class or method in the search box in the following site: https://docs.telerik.com/devtools/winforms/introduction. Select one of the results referring to the API documentation. As a result you will be navigated to the main page of the API reference instead of to the respective class or method. Refer to the Problem1.gif file. It seems that the search results from the API reference return old links for the previous API link pattern. 2. The search box in https://docs.telerik.com/devtools/winforms/api/ is significantly lagging while typing. We should consider performing the search operation after pressing Enter and not with each keystroke. Please refer to the Problem2.gif file. 3. When you scroll the navigation view on the left side to a certain position and select an article, the vertical scrollbar sometimes gets reset to the top position and you have to scroll back. (Note that this problem is not reproduced each time).
Workaround: set the property with code this.radListView1.ListViewElement.ViewElement.VScrollBar.MinThumbLength = 50;
How to reproduce: this.radLabel1.Font = new System.Drawing.Font("Arial", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); Workaround: public class MyRadLabel : RadLabel { public override string ThemeClassName { get { return typeof(RadLabel).FullName; } } protected override RadLabelElement CreateLabelElement() { return new MyRadLabelElement(); } } public class MyRadLabelElement : RadLabelElement { protected override Type ThemeEffectiveType { get { return typeof(RadLabelElement); } } protected override void CreateChildElements() { base.CreateChildElements(); MyTextPrimitive textPrimitive = new MyTextPrimitive(); textPrimitive.Alignment = ContentAlignment.MiddleLeft; textPrimitive.BindProperty(TextPrimitive.TextProperty, this, RadLabelElement.TextProperty, PropertyBindingOptions.TwoWay); textPrimitive.BindProperty(AlignmentProperty, this, RadLabelElement.TextAlignmentProperty, PropertyBindingOptions.OneWay); textPrimitive.SetValue(ImageAndTextLayoutPanel.IsTextPrimitiveProperty, true); textPrimitive.AutoEllipsis = true; textPrimitive.TextWrap = true; ImageAndTextLayoutPanel layoutPanel = this.FindDescendant<ImageAndTextLayoutPanel>(); if (layoutPanel != null) { layoutPanel.Children.RemoveAt(1); layoutPanel.Children.Add(textPrimitive); } } } public class MyTextPrimitive : TextPrimitive { public override Font GetScaledFont(float scale) { Screen screen = Screen.PrimaryScreen; SizeF startScale = new SizeF(1.0f, 1.0f); if (RadControl.EnableDpiScaling) { startScale = NativeMethods.GetMonitorDpi(screen, NativeMethods.DpiType.Effective); } SizeF paintScale = new SizeF(scale / startScale.Width, scale / startScale.Height); Font font = this.Font ?? Control.DefaultFont; string key = paintScale.ToString() + font.FontFamily.Name + font.Size + font.Style.ToString() + font.Unit.ToString() + font.GdiCharSet.ToString() + font.GdiVerticalFont.ToString(); if (this.ScaledFontsCache.ContainsKey(key)) { return this.ScaledFontsCache[key]; } Font scaledFont = new Font(font.FontFamily, font.Size * paintScale.Height, font.Style, font.Unit, font.GdiCharSet, font.GdiVerticalFont); this.ScaledFontsCache.Add(key, scaledFont); return scaledFont; } }
How to reproduce: store an image on the file and try to use it this way string path = @"D:\img.png"; this.radLabel1.Text = "<html><img src=" + path + "><b>Test</b></html>"; Workaround: if possible embed the image in the assembly and use it as a resource this.radLabel1.Text = "<html><img src=res:_1133506_RadLabelLinkHtmlLike.img.png><b>Test</b></html>";
Is it possible to add a Hamburger Menu to the Telerik UI for WinForms? like: https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/navigationview
To reproduce: Add some buttons to a form set the theme to Fluent and press the button using the space button Workaround: Use the attached theme.
Use attached project to reproduce. Workaround: Use attached theme.
Similar to Material Themes Blending (https://docs.telerik.com/devtools/winforms/tools/visual-style-builder/working-with-visual-style-builder/material-themes-blending) provide an easy way to change the palette for the Fluent themes.
To reproduce: - Open Theme Viewer, go ListView and sort it. - Change the theme to Fluent. Workaround: - Set the visibility of the item in the theme (see attached).
Workaround: use a bigger image Me.radCheckBox1.ButtonElement.CheckMarkPrimitive.CheckElement.ShouldPaint = False Dim dpi As Point = NativeMethods.GetSystemDpi() Dim scale As Integer = dpi.X If scale >= 300 Then Me.radCheckBox1.ButtonElement.CheckMarkPrimitive.Image = Image.FromFile("..\..\check-mark.png") ElseIf scale >= 200 Then '... Else '... End If
The ImageList property is visible in the Properties section of VisualStudio for RadTextBox, RadTextBoxControl etc.
How to reproduce: set the MinimumSize property of a RadButton in a DPI-aware app Workaround: Public Class RadForm1 Dim minMaxStack = New Stack(Of Dictionary(Of Control, Tuple(Of Size, Size)))() Sub New() InitializeComponent() End Sub Protected Overrides Sub HandleDpiChanged() Dim scaleFactor As Single = 1.0F Dim oldDpi = GetType(RadFormControlBase).GetField("oldDpi", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me) Dim currentDpi = GetType(RadFormControlBase).GetField("currentDpi", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me) If oldDpi <> 0 Then scaleFactor = CSng(currentDpi) / oldDpi ElseIf oldDpi = 0 Then scaleFactor = CSng(currentDpi) / 96.0F End If If scaleFactor = 1.0F Then Return End If Me.SaveMinMaxStates() MyBase.HandleDpiChanged() Me.RestoreMinMaxStates() End Sub Private Sub SaveMinMaxStates() If Me.minMaxStack Is Nothing Then Me.minMaxStack = New Stack(Of Dictionary(Of Control, Tuple(Of Size, Size)))() End If Dim minMax As New Dictionary(Of Control, Tuple(Of Size, Size))() Dim queue As New Queue(Of Control)() For Each ctrl As Control In Me.Controls queue.Enqueue(ctrl) Next While queue.Count > 0 Dim ctrl As Control = queue.Dequeue() If TypeOf ctrl Is RadControl Then minMax.Add(ctrl, New Tuple(Of Size, Size)(ctrl.MinimumSize, ctrl.MaximumSize)) ctrl.MinimumSize = Size.Empty ctrl.MaximumSize = Size.Empty End If For Each childControl As Control In ctrl.Controls queue.Enqueue(childControl) Next End While Me.minMaxStack.Push(minMax) End Sub Private Sub RestoreMinMaxStates() Dim minMax As Dictionary(Of Control, Tuple(Of Size, Size)) = Me.minMaxStack.Pop() Dim queue As New Queue(Of Control)() For Each ctrl As Control In Me.Controls queue.Enqueue(ctrl) Next While queue.Count > 0 Dim ctrl As Control = queue.Dequeue() If minMax.ContainsKey(ctrl) Then ctrl.MinimumSize = minMax(ctrl).Item1 ctrl.MaximumSize = minMax(ctrl).Item2 minMax.Remove(ctrl) End If For Each childControl As Control In ctrl.Controls queue.Enqueue(childControl) Next End While minMax.Clear() End Sub End Class
Extract the source in a folder like this: "Telerik UI for WinForms R3 2017" Workaround: Remove the spaces in the path.
Workaround: 1. Explicitly set the font of the checkbox with code. this.radCheckBox1.Font = new Font("Segoe UI", 9.0f, FontStyle.Regular); 2. Use the attached custom theme.