locked
How do you hide something, do something, then show something in a click event. RRS feed

  • Question

  • Say you have a simple TextBlock with a MouseLeftButtonDown.

    In that event I want to:

    1) Hide a Datagrid
    2) Do custom code to the datagrid
    3) Show the datagrid

    Right now I have this code:

    private void Sort_Click(object sender, MouseButtonEventArgs e)  {
    TextBlock button = sender as TextBlock;
    ResultGrid.Visibility =
    Visibility.Collapsed;
    _gridInfo.Sort(button.Tag.ToString());
    ResultGrid.Visibility =
    Visibility.Visible;
    }

    When I do the click, the DataGrid(ResultGrid) doesn't disappear, does 30 seconds of sorting, then reappear. It just stays visible, and sorts.

    Do I need to do a custom event handler to do these kinds of things?

    Thursday, November 26, 2009 12:54 PM

Answers

  •  I do not think that hiding the datagrid for 30 seconds while it sorts is a good idea.  I believe dispatcher.begininvoke will let you do it.  Personally I would use something like the silverlight toolkits BusyIndicator to show the app is doing something

     

    http://silverlight.codeplex.com/

    Thursday, November 26, 2009 1:12 PM

All replies

  •  I do not think that hiding the datagrid for 30 seconds while it sorts is a good idea.  I believe dispatcher.begininvoke will let you do it.  Personally I would use something like the silverlight toolkits BusyIndicator to show the app is doing something

     

    http://silverlight.codeplex.com/

    Thursday, November 26, 2009 1:12 PM
  • Hiding the DataGrid was just an example of trying to do something with the UI as work was going on...I'm not that much of a fail whale...hehe :)

    I'll read up on that dispatch thing...

    Friday, November 27, 2009 10:38 AM