Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / MeasureString
Created March 15, 2013 20:46
WPF Measure String
private static double GetStringWidth(string text, Control control)
{
Typeface typeface = new Typeface(control.FontFamily, control.FontStyle, control.FontWeight, control.FontStretch);
GlyphTypeface glyphTypeface;
if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
throw new InvalidOperationException("No glyph typeface found");
double size = control.FontSize;
@Vaccano
Vaccano / SimpleCommand.cs
Created January 10, 2011 19:33
SimpleCommand.cs
public class SimpleCommand<T> : ICommand
{
public Predicate<T> CanExecuteDelegate { get; set; }
public Action<T> ExecuteDelegate { get; set; }
#region ICommand Members
public bool CanExecute(object parameter)
{
if (CanExecuteDelegate != null)