WPF: List of fonts in combo

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

    #1

    WPF: List of fonts in combo

    I have a list of fonts in a combo. how to I make each item in the list use
    that font as it's (the item's) style similar to viewing a list of fonts in
    Word?

    <ComboBox Grid.Row="0" Grid.Column="1" x:Name="Font"
    VerticalAlignme nt="Top" Height="24" IsSynchronizedW ithCurrentItem= "True"
    ItemsSource="{x :Static Fonts.SystemFon tFamilies}"/>


    Thanks.

    --
    moondaddy@newsg roup.nospam


  • Linda Liu[MSFT]

    #2
    RE: WPF: List of fonts in combo

    Hi George,

    To get what you want, you need to implement a DataTemplate for the items of
    the ComboBox control.

    The following is a sample:

    <ComboBox ItemsSource="{x :Static Fonts.SystemFon tFamilies}">
    <ComboBox.ItemT emplate>
    <DataTemplate >
    <TextBlock Text="{Binding} " FontFamily="{Bi nding}"/>
    </DataTemplate>
    </ComboBox.ItemTe mplate>
    </ComboBox>

    Hope this helps.
    If you have any question, please feel free to let me know.

    Sincerely,
    Linda Liu
    Microsoft Online Community Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    msdnmg@microsof t.com.

    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscripti...ult.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscripti...t/default.aspx.
    =============== =============== =============== =====
    This posting is provided "AS IS" with no warranties, and confers no rights.

    Comment

    • not_a_commie

      #3
      Re: WPF: List of fonts in combo

      Rather than binding the item source, just fill the box in the owner's
      loaded event by looping through all the fonts in
      Fonts.SystmFont Families and making the ComboBoxItem.Fo ntFamily match
      the font name you put in the item.

      Comment

      • moondaddy

        #4
        Re: WPF: List of fonts in combo

        Thanks Linda, That was totaly perfect.

        "Linda Liu[MSFT]" <v-lliu@online.mic rosoft.comwrote in message
        news:TWPHPYN4IH A.1624@TK2MSFTN GHUB02.phx.gbl. ..
        Hi George,
        >
        To get what you want, you need to implement a DataTemplate for the items
        of
        the ComboBox control.
        >
        The following is a sample:
        >
        <ComboBox ItemsSource="{x :Static Fonts.SystemFon tFamilies}">
        <ComboBox.ItemT emplate>
        <DataTemplate >
        <TextBlock Text="{Binding} " FontFamily="{Bi nding}"/>
        </DataTemplate>
        </ComboBox.ItemTe mplate>
        </ComboBox>
        >
        Hope this helps.
        If you have any question, please feel free to let me know.
        >
        Sincerely,
        Linda Liu
        Microsoft Online Community Support
        >
        Delighting our customers is our #1 priority. We welcome your comments and
        suggestions about how we can improve the support we provide to you. Please
        feel free to let my manager know what you think of the level of service
        provided. You can send feedback directly to my manager at:
        msdnmg@microsof t.com.
        >
        =============== =============== =============== =====
        Get notification to my posts through email? Please refer to
        http://msdn.microsoft.com/subscripti...ult.aspx#notif
        ications.
        >
        Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
        where an initial response from the community or a Microsoft Support
        Engineer within 1 business day is acceptable. Please note that each follow
        up response may take approximately 2 business days as the support
        professional working with you may need further investigation to reach the
        most efficient resolution. The offering is not appropriate for situations
        that require urgent, real-time or phone-based interactions or complex
        project analysis and dump analysis issues. Issues of this nature are best
        handled working with a dedicated Microsoft Support Engineer by contacting
        Microsoft Customer Support Services (CSS) at
        http://msdn.microsoft.com/subscripti...t/default.aspx.
        =============== =============== =============== =====
        This posting is provided "AS IS" with no warranties, and confers no
        rights.
        >

        Comment

        Working...