0

I have a simple Silverlight 4 application and have added a child window to it. I am using the below code to open it on a button click. This seems like it should work, does it not?

public void btnAbout_Click(object sender, RoutedEventArgs e)
        {
            About aboutThis = new About();
            aboutThis.Show();
        }

The "About" class looks like this:

public partial class About : ChildWindow
    {
        public About()
        {
            InitializeComponent();
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
Matt
  • 5,542
  • 14
  • 48
  • 59

2 Answers2

1

I don't see any reason why it should not work.

Samples:

http://www.tanguay.info/web/index.php?pg=codeExamples&id=135

http://www.silverlighttoys.com/Tutorials.aspx?tutorial=2

What is your XAML like?

Andrei Drynov
  • 8,362
  • 6
  • 39
  • 39
  • me neither.. do you suppose it actually is showing but is somehow "behind" other content? – Matt Nov 02 '10 at 14:49
  • Tried in SL4 now and the result is weird - the default child window is actually shown, but as a tiny, tiny window - regardless of the XAML. – Andrei Drynov Nov 02 '10 at 16:22
  • MSDN sample works, though, so try checking your XAML: http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm#/?sref=ChildWindowLogin – Andrei Drynov Nov 02 '10 at 16:30
  • You will get the tiny, tiny window if for some reason your code doesn't execute the InitializeComponent() in your constructor. Are you SURE this is the exact code you have? InitializeComponent is what goes and reads the XAML and builds and renders the controls. – Erik Noren Nov 03 '10 at 22:08
  • Tried again: added a Child Window in VS2010 and called Show(). Works fine. – Andrei Drynov Nov 05 '10 at 11:52
0

Try setting the Width and Height to 600px by 600px of your About Childwindow from xaml.

Zain Shaikh
  • 6,013
  • 6
  • 41
  • 66