Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: Sorting Font Family list in the PropertyGrid

$
0
0
Hi,

One way is to use the ItemsSource attribute to create your own content for the ComboBox. When using System.Linq :
public class MyUserObject
{
 [ItemsSource( typeof( MyFontItemsSource ) )]
public FontFamily FontFamily { get; set; }
}

 public class MyFontItemsSource : IItemsSource
    {
      public Xceed.Wpf.Toolkit.PropertyGrid.Attributes.ItemCollection GetValues()
      {
        var fonts = Fonts.SystemFontFamilies.OrderBy(x => x.ToString());
        var fontCollection = new Xceed.Wpf.Toolkit.PropertyGrid.Attributes.ItemCollection();
        foreach( FontFamily fontFamily in fonts )
        {
          fontCollection.Add( fontFamily );
        }
        return fontCollection;
      }
    }

var selectedObject = new MyUserObject();
_propertyGrid.SelectedObject = selectedObject;

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>