Create DataTemplate in codebehind

Although Archedius’s method works, officially it is deprecated and instead recommended way to programmatically create a template is to load XAML from a string or a memory stream using the Load method of the XamlReader class like this… public DataTemplate Create(Type type) { StringReader stringReader = new StringReader( @”<DataTemplate xmlns=””http://schemas.microsoft.com/winfx/2006/xaml/presentation””> <” + type.Name + @” … Read more

passing the current Window as a CommandParameter

There are two ways I can of think to do this: Give the window a name (via a x:Name attribute on the Window tag, and then construct a binding like this (assumes the name of the window is ‘ThisWindow’): <Button Command=”CommandGetsCalled” CommandParameter=”{Binding ElementName=ThisWindow}” /> For something more general (doesn’t rely on giving the current Window … Read more

Assign Short Cut Key to a button in WPF

This is kind of old, but I ran into the same issue today. I found that the simplest solution is to just use an AccessText element for the button’s content. <Button Command=”{Binding SomeCommand}”> <AccessText>_Help</AccessText> </Button> When you press the Alt key, the ‘H’ will be underlined on the button. When you press the key combination … Read more

WPF Attached Events vs Non-Attached Events

The difference is mostly syntactic, both delegate references are being handled by WPF’s EventManager but what the attached events give you is the ability to declare generic functionality without needing to bloat all your classes’ implementation. In the case of a normal routed event, the class provides the interface to be able to at some … Read more

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