Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9225259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:32:00+00:00 2026-06-18T04:32:00+00:00

I have a two window basic system not using System.Windows.Forms but System.Windows.Controls, one of

  • 0

I have a two window basic system not using System.Windows.Forms but System.Windows.Controls, one of them creates a FontDialog, so I had to include the System.Windows.Forms, because otherwise I wouldn’t be able to have the font dialog. In the other window I have a RichTextBox which should use the font/size/style selected in the FontDialog of the other window.

This is the class for the window that creates the FontDialog:

public partial class Window1 : Window
{
    public FontDialog font;

    public Window1(String name)
    {
        InitializeComponent();
        this.textBox1.Text = name;
    }

    private void button2_Click(object sender, RoutedEventArgs e)
    {
        font = new FontDialog();
        font.ShowDialog();
    }
}

And here I call the Window1 and try to use its font.

private void button2_Click(object sender, RoutedEventArgs e)
{
    Window1 a = new Window1(this.name);
    a.ShowDialog();

    var cvt = new FontConverter();
    string s = cvt.ConvertToString(a.font.Font);

    Console.Out.WriteLine("Value is: " + s);

    System.Windows.Media.FontFamily g = (System.Windows.Media.FontFamily) cvt.ConvertFromString(s);

    if (g != null)
    {
         this.textBox2.FontFamily = g;
    }
}

It outputs exactly what is selected in the FontDialog, but then it crashes at the line “this.textBox2.FontFamily = g;”:

Value is: Microsoft Sans Serif; 8,25pt
'_.NetworkingGT_Incrementer.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase.resources\v4.0_4.0.0.0_pt-BR_31bf3856ad364e35\WindowsBase.resources.dll'
A first chance exception of type 'System.ArgumentException' occurred in WindowsBase.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
'_.NetworkingGT_Incrementer.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xaml.resources\v4.0_4.0.0.0_pt-BR_b77a5c561934e089\System.Xaml.resources.dll'
A first chance exception of type 'System.Xaml.XamlObjectWriterException' occurred in System.Xaml.dll
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:32:02+00:00Added an answer on June 18, 2026 at 4:32 am

    Solved:

    var cvt = new FontConverter();
    
    string s = cvt.ConvertToString(a.font.Font);
    
    Console.Out.WriteLine("Value is: " + s);
    
    System.Windows.Media.FontFamily g = new System.Windows.Media.FontFamily(s);
    
    Console.Out.WriteLine("Value is: " + g.ToString());
    
    this.textBox2.FontFamily = g;
    

    Both outputs are equal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two window form applications written in C, one holds a struct consisting
I have the following code which creates a simple window with two buttons which
I have the following extJs window which has two tabs in it. One of
I have a page with two buttons, one Button opens a popup window with
I have two windows application, one is a windows service which create EventWaitHandle and
Let's say I have two windows services running. One service is 'Polling' - it
I have two arrays one with OS's such as Ubuntu and Windows and another
I'm trying to have the content of two windows be shared, but it doesn't
I have an Android project with two activities. One is my main activity, using
I have two images on a WPF window that are on top of each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.