#915 – Delaying Generation of Expander Content

If you have a lot of content to display when an Expander is expanded and you want to delay loading of the content until the user actually opens the Expander, you can use the Expander’s Expanded event.

In the example below, the Expander contains a TextBlock, which we only load in the handler for the Expanded event.

        <Expander BorderBrush="DarkGray" Margin="0,5"
                  Header="Expand to See Something"
            <TextBlock Name="txtInfo"/>
        private void Expander_Expanded(object sender, RoutedEventArgs e)
            txtInfo.Text = string.Format("You expanded me at {0}", DateTime.Now);

When we run this example, the date/time displayed is the date/time that you expand the Expander.


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #915 – Delaying Generation of Expander Content

  1. Pingback: Dew Drop – September 26, 2013 (#1,632) | Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: