Custom Controls and stretching RRS feed

  • Question

  • I have a main control that is just a grid with a few rows.  Inside one of the grid rows I have added several custom controls, which contain treeviews.

    When I click on a treeview item, I want to bring up a detail window that covers the whole canvas.  The problem I am having is that the detail window stays within the bounds of the custom control and does not expand to fill the entire canvas.


    Wednesday, August 26, 2009 1:09 PM


All replies

  • Hi,

    What control are you using to display your detail window?  You should just be able to place your detail window in a standard Popup control and set the IsOpen property to show/hide.  The Popup control is always rendered on top of everything else.

    Thursday, August 27, 2009 3:48 AM
  • That got me a little further.  The pop up is on top of everything and goes beyond the bounds of the control that fired the event, but it is anchored to that control. 

    How chould I anchor it to the top left corner of the IE window so it covers the whole canvas area?



    Thursday, August 27, 2009 8:29 AM
  • Here is the prototype site I am working on. 


    Notice how the pop ups on the treeviews are achored to the treeview they are fired from.

    Thursday, August 27, 2009 9:05 AM
  • How do you create your popup? If you create your popup with xaml inside another element that popup will be position relative to its parent. Create your popup without parent and it will be position relative to silverlight window:

    myPopup = new System.Windows.Controls.Primitives.Popup();
    myPopup.Child = new Image() { Source = Thumbnail };
    myPopup.IsOpen = true;
    Friday, August 28, 2009 6:22 AM
  • I was trying to keep everything self contained within the control.  I was hoping to stick with the idea that one of the the main purposes of user controls is reusability.  I want to be able to create this treeview control, drop it on any XAML page, and set the itemsource, without making code changes to the page I put it on. 

    In other words I am trying to extend its functionality. If I tied the popup event and control to main XAML page, the custom treeview control is no longer resuable.

    Is there anyway a control can get the handle of its parent object?  Maybe I can get the (x,y) location of the custom control and shift the (x,y) location of the popup accordingly?  Then I could set the height and width of the pop up to match the parent, which in this case is the main canvas?



     Thanks for everyone's help so far.

    Friday, August 28, 2009 8:49 AM
  • After much pain the answer was already done for me. 




    The ChildWindowDemo did exactly what I wanted, and much better than I could have ever done.


    Thanks again all.

    Friday, August 28, 2009 12:30 PM