This project has moved and is read-only. For the latest updates, please go here.

Setting ExpansionContentTemplate

Sep 27, 2007 at 10:31 PM
I basically want the ExpansionContent to show up in an area in the TaskDialog with a vertical and horizontal scroll bar. I am trying to set the ExpansionContentTemplate using a data template loaded from a XAML Resource.

Here is my data template:
<DataTemplate x:Key="MyTemplate">
<Border ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="5" BorderBrush="Red">
<DockPanel HorizontalAlignment="Center">
<TextBlock Name="ExpansionDisplayText" Text="{Binding Path=ExpansionContent}"/>

Here is My C# Code:
TaskDialog dialog = new TaskDialog();
dialog.ExpansionContentTemplate = (DataTemplate)this.FindResource("MyTemplate");
dialog.ExpansionContent = formatter.Writer.ToString();

When the Task Dialog renders, and the expansion button is clicked, the area being expanded displays and there is a big red border around the area but the text inh the ExpansionContent is not set.

How can i fix this?
Oct 7, 2008 at 6:39 PM
This is an old post that slipped by me - sorry! I hope you've figured this out already, but thought it might help others who encounter the same problem.

The problem in your code is that you should use an empty binding, i.e. Text="{Binding}". When WPF applies the content template, it sets the content (in this case, the value of the ExpantionContent property) as the DataContext.