Skip to main content

Answered Question How to show XAML file as model dialog?RSS Feed

(0)

pmkr
pmkr

Member

Member

17 points

31 Posts

How to show XAML file as model dialog?

Hi, I have 3 XAML files in my project. When I click on button I want to show XAML file as model dialog. How can I do that. Any help would be appreciated.

Thanks

mustafacakir
mustafac...

Member

Member

36 points

39 Posts

Re: How to show XAML file as model dialog?

Hi;

you can use this methot

MySoftClass=projectName

path = "MySoftClass.ResourceTemplates.xaml";

or

path =""MySoftClass.Generic.xaml";



public MyContollSoft(String Path)

{

Assembly assembly = Assembly.GetExecutingAssembly();
// string fooResourceName = "MySoftClass.generic.xaml";    you can read like this
string fooResourceName = Path;
using (Stream s = assembly.GetManifestResourceStream(fooResourceName))
{
StreamReader reader = new StreamReader(s);
string xaml = reader.ReadToEnd();
ResourceDictionary rdd = (ResourceDictionary)XamlReader.Load(xaml);
Style myStyle = rdd["myStyle"] as Style;
if (myStyle != null)
{
this.Style = myStyle;
}
reader.Close();
s.Close();
}
DefaultStyleKey =
typeof(MyContollSoft);
}


 

pmkr
pmkr

Member

Member

17 points

31 Posts

Re: How to show XAML file as model dialog?

Hi Thanks for your reply. I couldn't understand this code. Could you please explain this?. What is this MySoftClass=projectName  meaning. and there is not intellisense for assembly. How can I get this Assembly abject?

Thanks

mustafacakir
mustafac...

Member

Member

36 points

39 Posts

Answered Question

Re: How to show XAML file as model dialog?

you can get Assembly name

    Assembly assembly = Assembly.GetExecutingAssembly();

            // Retrieve a list of resource names contained by the assembly.
            string[] resourceNames = assembly.GetManifestResourceNames();
            foreach (string resourceName in resourceNames)
            {
                Console.WriteLine(resourceName);
            }

sladapter
sladapter

All-Star

All-Star

20775 points

3,818 Posts

Answered Question

Re: How to show XAML file as model dialog?

There is no Modal Dialog in Sivlerlight. But you can simulate one by putting your UserControl to a Canvas and make this Canvas on top of everything on your page. Between your top Canvas and the rest of the page you put a simi-transparent rectangle to mask the rest of the page. So no user input is accepted in the main page until you close your Top canvas (make it visibility=Collapsed).

Take a look at this Scott Gu's tutorial.  It shows you how to display a detailed section data in a "Modal" box:  http://weblogs.asp.net/scottgu/archive/2008/02/22/first-look-at-silverlight-2.aspx

If you want that box be able to be draggable, take a look that this code I put together. It's a resizable and draggble popup window you can put any content in it. You can also make it "Modal". You can download the code.

http://silverlight.net/forums/p/12467/41324.aspx#41324

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

Keith.Mahoney
Keith.Ma...

Participant

Participant

872 points

131 Posts

Microsoft
Answered Question

Re: How to show XAML file as model dialog?

Hi pmkr,
I assume that the three xaml files are UserControls in your project?
The easiest way to get modal-dialog-like behaviour is Silverlight is to place your UserControl into a PopUp control.

The following links should be helpful
http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.popup(VS.95).aspx
http://blogs.msdn.com/silverlight_sdk/archive/2008/04/18/playing-with-the-popup-control.aspx

Keith Mahoney
Silverlight SDET
Microsoft
  • Unanswered Question
  • Answered Question
  • Announcement