Setting design time DataContext on a Window is giving a compiler error?

I needed to add the mc:Ignorable=”d” attribute to the Window tag. Essentially I learned something new. The d: namespace prefix that Expression Blend/Visual Studio designer acknowledges is actually ignored/”commented out” by the real compiler/xaml parser! <Window … xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″ mc:Ignorable=”d” xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″ … /> The following was taken from Nathan, Adam (2010-06-04). WPF 4 Unleashed (Kindle Locations … Read more

Difference between Control Template and DataTemplate in WPF

Typically a control is rendered for its own sake, and doesn’t reflect underlying data. For example, a Button wouldn’t be bound to a business object – it’s there purely so it can be clicked on. A ContentControl or ListBox, however, generally appear so that they can present data for the user. A DataTemplate, therefore, is … Read more

How to bind multiple values to a single WPF TextBlock?

You can use a MultiBinding combined with the StringFormat property. Usage would resemble the following: <TextBlock> <TextBlock.Text> <MultiBinding StringFormat=”{}{0} + {1}”> <Binding Path=”Name” /> <Binding Path=”ID” /> </MultiBinding> </TextBlock.Text> </TextBlock> Giving Name a value of Foo and ID a value of 1, your output in the TextBlock would then be Foo + 1. Note: This … Read more

Text vertical alignment in WPF TextBlock

A Textblock itself can’t do vertical alignment The best way to do this that I’ve found is to put the textblock inside a border, so the border does the alignment for you. <Border BorderBrush=”{x:Null}” Height=”50″> <TextBlock TextWrapping=”Wrap” Text=”Some Text” VerticalAlignment=”Center”/> </Border> Note: This is functionally equivalent to using a grid, it just depends how you … Read more

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