How to set the default font for a WPF application?

Assuming your Window subclasses don’t override DefaultStyleKey, you can simply add it to your Window style, since TextElement.FontFamilyProperty is an inherited property: <Style TargetType=”{x:Type Window}”> <Setter Property=”FontFamily” Value=”Segoe UI” /> </Style> You also need to add the following to your App constructor after the InitializeComponent call: FrameworkElement.StyleProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata { DefaultValue = FindResource(typeof(Window)) }); How … Read more

Error setting a default null value for an annotation’s field

I don’t know why, but the JLS is very clear: Discussion Note that null is not a legal element value for any element type. And the definition of a default element is: DefaultValue: default ElementValue Unfortunately I keep finding that the new language features (Enums and now Annotations) have very unhelpful compiler error messages when … Read more

Setting default value for Foreign Key attribute

I would modify @vault’s answer above slightly (this may be a new feature). It is definitely desirable to refer to the field by a natural name. However instead of overriding the Manager I would simply use the to_field param of ForeignKey: class Country(models.Model): sigla = models.CharField(max_length=5, unique=True) def __unicode__(self): return u’%s’ % self.sigla class City(models.Model): … Read more

Is there a reasonable approach to “default” type parameters in C# Generics?

Subclassing is the best option. I would subclass your main generic class: class BaseGeneric<T,U> with a specific class class MyGeneric<T> : BaseGeneric<T, string> This makes it easy to keep your logic in one place (the base class), but also easy to provide both usage options. Depending on the class, there is probably very little extra … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)