wpf/c#: convert string to fontweight

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • moondaddy

    #1

    wpf/c#: convert string to fontweight

    How can I convert a string to a FontFamily?

    Suto code:
    String sFont = "Bold";
    FontFamily ff = (FontFamily)sFo nt;

    Thanks.

    --
    moondaddy@newsg roup.nospam


  • moondaddy

    #2
    Re: wpf/c#: convert string to fontweight

    Sorry, I got tottaly messed up on the sample code in the first post.

    it should be:
    Suto code:
    string sWeight = "Bold";
    FontWeight fw = (FontWeight)sWe ight;

    Thanks.


    "moondaddy" <moondaddy@news group.nospamwro te in message
    news:%23dU0Qer5 IHA.1192@TK2MSF TNGP05.phx.gbl. ..
    How can I convert a string to a FontFamily?
    >
    Suto code:
    String sFont = "Bold";
    FontFamily ff = (FontFamily)sFo nt;
    >
    Thanks.
    >
    --
    moondaddy@newsg roup.nospam
    >

    Comment

    • desirix

      #3
      Re: wpf/c#: convert string to fontweight

      Hi,

      to convert a type of String to a type of FontWeight there's a class called
      FontWeightConve rter.
      Here's the code for your example:

      string sWeight = "Bold";
      FontWeight fw = (FontWeight)new
      FontWeightConve rter().ConvertF romString(sWeig ht);

      I hope it helps.

      Regards,
      Denis

      "moondaddy" <moondaddy@news group.nospamsch rieb im Newsbeitrag
      news:OfIGpir5IH A.4344@TK2MSFTN GP03.phx.gbl...
      Sorry, I got tottaly messed up on the sample code in the first post.
      >
      it should be:
      Suto code:
      string sWeight = "Bold";
      FontWeight fw = (FontWeight)sWe ight;
      >
      Thanks.
      >
      >
      "moondaddy" <moondaddy@news group.nospamwro te in message
      news:%23dU0Qer5 IHA.1192@TK2MSF TNGP05.phx.gbl. ..
      >How can I convert a string to a FontFamily?
      >>
      >Suto code:
      >String sFont = "Bold";
      >FontFamily ff = (FontFamily)sFo nt;
      >>
      >Thanks.
      >>
      >--
      >moondaddy@newsg roup.nospam
      >>
      >
      >

      Comment

      Working...