G. V.
G. V.

Reputation: 1

How do I instruct Blend to generate working resource-loading code?

I'm designing a user interface in Blend, and need to open a new window on activating a button. The code that does this is very simple:

        var w = new Window1();
        w.Owner = this;
        _ = w.ShowDialog();

However, the new window fails to load its sample data. The failing code is auto-generated and can't really be influenced by me:

        Uri resourceUri = new Uri("ms-appx:/SampleData/Users/Users.xaml", UriKind.RelativeOrAbsolute);
        Application.LoadComponent(this, resourceUri);

The latter line fails with an ArgumentException: Cannot use absolute URI.

How do I open a new window in such a way that sample data may be loaded correctly?

Upvotes: 0

Views: 38

Answers (1)

Hoyt_Ren
Hoyt_Ren

Reputation: 11

Remove ms-appx: and it works.
It should looks like: Uri("/SampleData/Users/Users.xaml", UriKind ...

Upvotes: 0

Related Questions