Hello,
HtmlDataProvider will throw an exception on export or when used by a RadRichTextBox, when using a html containing the length value "NaN", which doesn't seem to be a standard approved value, but nevetheless it is a special case because other invaild values are simply ignored while this one triggers two exceptions - one of which is hard to catch and crashes the whole application.
Code to reproduce: Console App / .Net Framework 4.8 / Package Telerik.Windows.Documents.FormatProviders.Html.for.Wpf 2022.3.912
using System;
using Telerik.Windows.Documents.FormatProviders.Html;
using Telerik.Windows.Documents.Model;
namespaceHtmlProviderCrash
{
internalclassProgram
{
static void Main(string[] args)
{
var htmlContent = "<img src=\"https://static.cleverpush.com/notification/icon/92fYF7FtKbthsezwS.png?element=Le7adDwC\" " +
"alt=\"\" style=\"display: inline-table;max-width: 100%;width: 300px;\" width=\"300\" height=\"NaN\" class=\"cp-element-image light-img\">";
HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
RadDocument document = htmlProvider.Import(htmlContent);
try
{
var export = htmlProvider.Export(document);
}
catch (Exception ex)
{
var ka = ex.ToString();
}
while (Console.ReadKey().KeyChar != 'x') { }
}
}
}
Message "MeasureOverride returned NaN: Telerik.Windows.Documents.Layout.ImageLayoutBox" string at Telerik.Windows.Documents.Layout.LayoutElement.Measure(SizeF availableSize) at Telerik.Windows.Documents.Layout.ParagraphLayoutBox.MeasureCurrentGroupSize(ParagraphLayoutBoxMeasureContext context, SizeF measureSize, Func`1 GetCurrentXDefaultValue, LinkedList`1 currentGroupInlines) at Telerik.Windows.Documents.Layout.ParagraphLayoutBox.MeasureOverride(SizeF availableSize) at Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(SizeF availableSize) at Telerik.Windows.Documents.Layout.LayoutElement.Measure(SizeF availableSize) at Telerik.Windows.Documents.Layout.SectionLayoutBox.MeasureOverrideInternal(SizeF availableSize) at Telerik.Windows.Documents.Layout.SectionLayoutBox.MeasureOverride(SizeF availableSize) at Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(SizeF availableSize) at Telerik.Windows.Documents.Layout.LayoutElement.Measure(SizeF availableSize) at Telerik.Windows.Documents.Layout.DocumentLayoutBox.MeasureOverrideInternal(SizeF availableSize) at Telerik.Windows.Documents.Layout.DocumentLayoutBox.MeasureOverride(SizeF availableSize) at Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(SizeF availableSize) at Telerik.Windows.Documents.Layout.LayoutElement.Measure(SizeF availableSize) at Telerik.Windows.Documents.Model.RadDocument.Measure(SizeF measureSize) at Telerik.Windows.Documents.Model.RadDocument.MeasureAndArrangeInDefaultSize() at Telerik.Windows.Documents.Model.RadDocument.EnsureDocumentMeasuredAndArranged() at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.Export(RadDocument document, Stream output) at Telerik.Windows.Documents.FormatProviders.Html.HtmlFormatProvider.Export(RadDocument document, Stream output) at Telerik.Windows.Documents.FormatProviders.Html.HtmlFormatProvider.Export(RadDocument document) at HtmlProviderCrash.Program.Main(String[] args)
Message "The image data generated an overflow during processing"
at System.Windows.Media.Imaging.TransformedBitmap.FinalizeCreation() in System.Windows.Media.Imaging\TransformedBitmap.cs:line 216
at System.Windows.Media.Imaging.TransformedBitmap.EndInit() in System.Windows.Media.Imaging\TransformedBitmap.cs:line 112
at System.Windows.Media.Imaging.BitmapImage.FinalizeCreation() in System.Windows.Media.Imaging\BitmapImage.cs:line 505
at System.Windows.Media.Imaging.BitmapImage.EndInit() in System.Windows.Media.Imaging\BitmapImage.cs:line 319
at Telerik.Windows.Documents.Model.ImageDocumentElementHelper.CreateImageSourceCore(BitmapCreateOptions createOptions, Byte[] bytes, Size renderingSize, String& extension, Byte[]& resultBytes)
at Telerik.Windows.Documents.Model.ImageDocumentElementHelper.CreateImageSource(Byte[] bytes, Size imageSize, Size scaleFactor, String& extension, Byte[]& resultBytes)
at Telerik.Windows.Documents.Model.ImageDocumentElementHelper.InitializeRawImageData(IImageDocumentElement imageElement, Byte[] bytes, Size scaleFactor, String& extension)
at Telerik.Windows.Documents.Model.ImageDocumentElementHelper.InitInternal(IImageDocumentElement imageElement, Byte[] bytes, Size size, String extension, Boolean isUserInitiated)
at Telerik.Windows.Documents.Model.ImageInline.InitImageElementFromUriStream(Stream stream)
at Telerik.Windows.Documents.Model.ImageInline.<SetStreamFromUriSource>b__0(Object s, StreamReadyEventArgs a)
at Telerik.Windows.Documents.Utils.ResourceStreamLocator.OnStreamReady()
at Telerik.Windows.Documents.Utils.ResourceStreamLocator.<GetStreamAsync>b__0(Object sender, OpenReadCompletedEventArgs e)
at System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)
at System.Net.WebClient.OpenReadOperationCompleted(Object arg)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
A SocketException can occur when the ImageInline source is assigned to a link pointing to a picture on a remote server (a website). For example: UriSource ="https://docs.telerik.com/devtools/wpf/knowledge-base/images/kb-chartview-categorical-and-datetime-axis-0.png"
This could happen during the fetching of the image stream. In some cases, the server may give a NetworkStream or ConnectionStream, or similar Stream implementation, which keeps an open connection between the application and the server. If the connection get severed during the stream reading, an exception is thrown.
The exception message is: "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
The stacktrace is:
Exception Info: System.Net.Sockets.SocketException
at System.Net.Sockets.NetworkStream.Read(Byte[], Int32, Int32)
Inner Exception:
Exception Info: System.IO.IOException
at System.Net.ConnectStream.Read(Byte[], Int32, Int32)
at System.IO.Stream.InternalCopyTo(System.IO.Stream, Int32)
at Telerik.Windows.Documents.Layout.ExtensionMethods.ToMemoryStream(System.IO.Stream)
at Telerik.Windows.Documents.Model.ImageInline.<SetStreamFromUriSource>b__0(System.Object, StreamReadyEventArgs)
at Telerik.Windows.Documents.Utils.ResourceStreamLocator.OnStreamReady()
at System.Net.WebClient.OnOpenReadCompleted(System.Net.OpenReadCompletedEventArgs)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
If you drag the pane from one RadDocking element to another, the ActivePane of the docking that started the drag operation is not cleared. The ActivePane should be updated (set to null, or updated in accordance to the PaneActivationMode setting) because the corresponding pane is no longer in this RadDocking instance.
To work this around, you can subscribe to and manually update the ActivePane property.
private void RadDocking_LayoutChangeEnded(object? sender, EventArgs e)
{
var docking = (RadDocking)sender;
if (docking.ActivePane != null && !docking.Panes.OfType<RadPane>().Contains(docking.ActivePane))
{
docking.ActivePane = null;
}
}
The selection with the Shift key when SelectionMode=Extended no longer works in the default Nested rendering mode of RadGridView. This reproduces only when the data view is grouped.
To work this around, set the GroupRenderMode property of RadGridView to Flat.
<telerik:RadGridView GroupRenderMode="Flat" />
ArgumentExeption when typing a specific combination with the new Japanese IME.
Steps to reproduce:
Expected should work like in the standard text box.
The GridViewSelectColumn displays a CheckBox in its header, which selects all rows in the column. If the CheckBox is unchecked, and you click it to check the items, the items get selected/checked. However, the CheckBox doesn't get check until the second click.
This reproduces only when the RadGridView is grouped and also the groups are collapsed so that no data records are visible.
To work this around, you can replace the default CheckBox with a new one in the column's Header. Then, manually select and deselect the items. You can use the CheckBox MouseLeftButtonDown or Checked/Unchecked events. Note that it is important to wrap the CheckBox in the Header, in another control (like a Grid in the example below), in order to avoid the default RadGridView logic to kick-in.
<telerik:GridViewSelectColumn>
<telerik:GridViewSelectColumn.Header>
<Grid>
<CheckBox PreviewMouseLeftButtonDown="CheckBox_PreviewMouseLeftButtonDown"/>
</Grid>
</telerik:GridViewSelectColumn.Header>
</telerik:GridViewSelectColumn>
private void CheckBox_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
var checkBox = (CheckBox)sender;
if (checkBox.IsChecked.Value)
{
this.GridView.SelectedItems.Clear();
}
else
{
this.GridView.SelectAll();
}
}
Hi Telerik-Team,
the 2024.4.X release of UI for WPF seems to no longer render pdf files correctly. It looks like as if the PdfViewer just renders the document as a single huge page.
An application that uses those references:
<PackageReference Include="Telerik.Windows.Controls.for.Wpf.Xaml" Version="2024.3.924" />
<PackageReference Include="Telerik.Windows.Controls.FixedDocumentViewers.for.Wpf.Xaml" Version="2024.3.924" />
<PackageReference Include="Telerik.Windows.Documents.Core" Version="2024.3.806" />
<PackageReference Include="Telerik.Windows.Documents.Fixed" Version="2024.3.806" />
<PackageReference Include="Telerik.Windows.Zip" Version="2024.3.806" />
works as expected. Once you change those to:
<PackageReference Include="Telerik.Windows.Controls.for.Wpf.Xaml" Version="2024.4.1111" />
<PackageReference Include="Telerik.Windows.Controls.FixedDocumentViewers.for.Wpf.Xaml" Version="2024.4.1111" />
<PackageReference Include="Telerik.Windows.Documents.Core" Version="2024.4.106" />
<PackageReference Include="Telerik.Windows.Documents.Fixed" Version="2024.4.106" />
<PackageReference Include="Telerik.Windows.Zip" Version="2024.4.106" />
the renderer stops working.
I have attached a VS solution with a pdf file that reproduces this
When the RadGridView is filtered you can get all items in the data view using the Items collection property of the control. The count can be accessed with the gridView.Items.Count property.
If the RadGridView is grouped and then filtered, the Items.Count no longer returns the correct value. The count doesn't take into account the items that are in collapsed groups. Instead the count contains only the expanded group objects.
To work this around, use the following code instead of gridView.Items.Count.
int count = gridView.Items.OfType<object>().Count();
This action is usually linked to a Button field and with it, the user of the application may revert all field values to their defaults.