Thursday, January 15, 2009

Outlook 2003 addin having issues?

If you're outlook 2003 addin is failing and outlook is only telling you that your plugin was disabled since it encountered an error, you can obtain the exception by starting outlook like this from the command line:

> set VSTO_SUPPRESSDISPLAYALERTS=0
> C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE


The familiar debugging box should then pop up telling you why your addin failed. If it doesn't pop up make sure that the value for the registry key at HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\Addins\YourAddInName\LoadBehavior = 3

Wednesday, January 14, 2009

Sorting a ListView in WPF

Sorting a ListView in WPF was really hard for me to figure out, but I found this solution in WPF Unleashed:


myListView.Items.SortDescriptions.Clear();
myListView.Items.SortDescriptions.Add(new SortDescription("AttributeName", ListSortDirection.Ascending));


This will keep the listview sorted even if it is bound to an ObservableCollection.

Tuesday, January 13, 2009

WPF Dynamic Auto Width

If you want to update your WPF interface dynamically and need to set an element's width to "Auto" as it's called in XAML, you can just set it's width to Double.NaN:


element.Width = Double.NaN;