Setting Spreadsheet Font in a WPF app

2 Answers 18 Views
SpreadProcessing
Neil N
Top achievements
Rank 2
Iron
Iron
Veteran
Neil N asked on 08 Apr 2025, 08:25 PM

We need to set a spreadsheet font to Courier New in a WPF app using telerik.ui.for.wpf.60.xaml\2024.2.514.  As a first step, we do:

using System.Windows;
using Telerik.Documents.Common.Model;

namespace WpfApp4;

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        var fontFamily = new ThemableFontFamily("Courier New");
    }
}

Which is fine until we add a required cross-platform project referencing telerik.documents.core\2024.2.426

Then we get:

The type 'ThemableFontFamily' exists in both 'Telerik.Documents.Core, Version=2024.2.426.20, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' and 'Telerik.Windows.Documents.Core, Version=2024.2.426.60, Culture=neutral, PublicKeyToken=5803cfa389c90ce7'

Ambiguous reference.
Candidates are:
Telerik.Documents.Common.Model.ThemableColor
Telerik.Documents.Common.Model.ThemableColor

What is the proper fix for this to reference the version in the WPF app project?

2 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 09 Apr 2025, 05:49 AM

Hello, Neil,

The Telerik Document Processing libraries are available in .NET Framework, .NET Core/.NET 6/.NET 8/.NET 9 (or newer) for Windows and .NET Standard compatible versions. All versions are available as NuGet packages. The assemblies/packages for .NET Standard do not contain the word Windows in their name. Learn What Versions of Document Processing Libraries are Distributed with the Telerik Products.

In a WPF project, you need to use the assemblies containing the word Windows and avoid mixing .NET Framework and .NET Standard compatible versions.

I hope you find this information helpful. Please, let me know if there is anything else I can assist you with.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Neil N
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 09 Apr 2025, 12:29 PM

Hi  Dess,

Please re-read what I wrote. The projects are using the proper libraries. The WPF project is using telerik.ui.for.wpf.60.xaml.   The cross-platform .NET Standard project is using telerik.documents.core.  It can't be an uncommon scenario where a solution has both platform-specific projects and cross-platform projects.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 10 Apr 2025, 10:15 AM

Hi, Neil,

Thank you for the provided additional clarification which helped me to get better understanding of the scenario you need to handle. I have created the following projects:

- One .NET Framework Console application having the Telerik.UI.for.Wpf.60.Xaml NuGet package installed. It is important to use the .NET Framework assets here.

- One .NET Standard Console application having the Telerik.Documents.Core NuGet package installed. It is important to use the .NET Standard assets here.

The second project is added as a reference to the first project:

Indeed, in this case the following error message is expected to be displayed since the namespace is identical in both assemblies/NuGet packages:

It is a common scenario which has a common resolution using extern alias. A similar approach is demonstrated in the following KB article: https://docs.telerik.com/devtools/document-processing/knowledge-base/resolve-compile-time-error-radpdfprocessing-telerik-reporting 

I used the same steps in my sample application discussed in this thread:

extern alias NetFramework;

using NetFramework::Telerik.Documents.Common.Model;


namespace _1684241NetFramework
{
    internal class Program
    {
        static void Main(string[] args)
        {
            ThemableFontFamily fontFamily = new ThemableFontFamily("Courier New");
        }
    }
}

I have attached the two projects. Please give them a try and let me know how this approach works on your end.

 

 

Tags
SpreadProcessing
Asked by
Neil N
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or