Register  Login
Forum
Subject: Hi.....Problem using page switch Method in SLD
Prev Next
You are not authorized to post a reply.

Author Messages
Alex MasitaUser is Offline

Posts:4

10/21/2009 6:40 AM  
Great work with SLD. Recently decided to create a DNN Silverlight Hotel Reservation system and I am using SLD. I Initially had a problem with using page switching in the SLD where I would have one parent container Pageswitcher.xaml loading child user controls depending on the buttons pressed. I figured my way around it but now I have another problem. After creating another user control 'CheckAvailability.xaml' and adding a silverlight Datagrid, I cannot load the user control in the page switcher. On removing the datagrid, the usercontrol loads fine! This problem seemingly appears to occur when I reference a new library that was not part of the original silverlight SDK release, hence, I cannot add new controls such as DomainUpDown and Timepicker that need me to add a new reference.

The error I get whenever I add a new reference is:

Could not load file or assembly 'System.Windows.Controls.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Strangely, If I right click the silverlight project in DNN to browse it, it opens outside of DNN and allows me to navigate to the CheckAvailability.xaml with the references Added (The datagrid and DomainUpdown now show!) meaning, the problem cannot be even the references but the way it loads in DNN and SLD module. Any ideas on how I can solve this problem? Kind regards, Alex.
Michael WashingtonUser is Offline

Posts:64

10/21/2009 7:42 AM  
Are you using SilverlightDesktop modules that are uploaded to the site or some other method?

You mention "page switching" and I don't understand what you are referring to.
Alex MasitaUser is Offline

Posts:4

10/21/2009 8:46 AM  
Hi Micheal,
Thanks for your prompt response! Let me clarify. I downloaded your latest vb install version of SilverlightDesktop Module for DNN. I code in vb. Page switching is a methodology that some .net developers are using for implementing navigation within silverlight where basically, you have a container parent user control(I call it PageSwitcher.xaml with code behind) which is loaded by the app.xaml.vb. New custom pages (usercontrols) can be loaded into the content property of this (PageSwitcher.xaml) depending on buttons that you have configured to switch between various pages. The functionality for switching is written in a shared class file which I call Switcher. The switcher class has an overloaded Switch method with a usercontrol parameter for passing a new custom page which is set to be the new content for PageSwitcher.xaml. The second Switch Method has both a usercontrol parameter and an object parameter for passing business objects from one custom page to another. Quite a neat navigation procedure if you ask me. Now, under normal circumstances when creating a silverlight application, the RootVisual of App.Xaml.vb would be set to PageSwitcher.Xaml parent Container but this implementation could not run in you SLD(SilverlightDesktop for DNN) because I discovered from your documentation that SLD has it's own App.Xaml and App.Xaml.vb which loads usercontrols and not Applications. So to solve the problem, I went to the module configuration page. I left the assembly to the .Xap file I set earlier and changed the target Class to the PageSwitcher.Xaml parent user Control.

I now transferred the Page Load and Switching implementations from the App.Xaml.vb to the PageSwitcher.Xaml.vb and the ageswitching worked perfectly (I will provide the code files for the PageSwitcher.Xaml User control and the Switcher Class file at the bottom.)

This is now where the problem starts. For new custom pages that I create that DO NOT need me to add a new reference to new libraries(provided by the latest release of Silverlight 2 Toolkit from Microsoft), the pages load normally. But when I create a page that needs a Datagrid or the NumericUpDown or any other new Controls that need a new reference to be added to the silverlight Application, I get this error:

Could not load file or assembly 'System.Windows.Controls.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I only get this error when I launch this application from DNN silverlightdesktop. If I load the project normally, the Datagrid and All the new Controls that need a new reference load Normally. Meaning the problem has to be with the way the libraries load in DNN SLD. Do you now understand the problem? The Switcher Class and the PageSwitcher Class are pasted below......

Partial Public Class PageSwitcher
Inherits UserControl

Public Sub New
InitializeComponent()
AddHandler Loaded, AddressOf page_Loaded

End Sub

'' first overload
Public Sub Navigate(ByVal nextPage As UserControl)
'Me.Content = nextPage
MyUserControl.SetValue(ContentProperty, nextPage)
End Sub

Public Sub page_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
Try
AddHandler btnManageGuests.Click, AddressOf Manage_Guests
AddHandler btnCheckAvailability.Click, AddressOf Check_Availability
Switcher.pageSwitcher = Me
Switcher.Switch(New Page)
Catch ex As Exception
Windows.Browser.HtmlPage.Window.Alert(ex.StackTrace)
End Try
End Sub
'' second overload
Public Sub Navigate(ByVal nextPage As UserControl, ByVal state As Object)
'Me.Content = nextPage
MyUserControl.SetValue(ContentProperty, nextPage)
Dim s As ISwitchable = TryCast(nextPage, ISwitchable)
If s IsNot Nothing Then
s.UtilizeState(state)
Else
Throw New ArgumentException("nextPage is not ISwitchable! " _
& nextPage.Name.ToString())
End If
End Sub

Public Sub Manage_Guests(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Try
Switcher.Switch(New ManageGuests, Me.Tag)
Catch ex As Exception
Windows.Browser.HtmlPage.Window.Alert(ex.Message)
End Try
End Sub

Public Sub Check_Availability(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Try
Switcher.Switch(New CheckAvailability, Me.Tag)
Catch ex As Exception
Windows.Browser.HtmlPage.Window.Alert(ex.Message)
End Try
End Sub


Public Sub Go_Home(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Try
Switcher.Switch(New Home)
Catch ex As Exception
Windows.Browser.HtmlPage.Window.Alert(ex.Message)
End Try
End Sub
End Class

SWICHER.XAML

Public NotInheritable Class Switcher
Public Shared pageSwitcher As PageSwitcher

Private Sub New()
End Sub
Public Shared Sub Switch(ByVal newPage As UserControl)
pageSwitcher.Navigate(newPage)
End Sub

Public Shared Sub Switch(ByVal newPage As UserControl, ByVal state As Object)
pageSwitcher.Navigate(newPage, state)
End Sub
End Class

Let me also see if I could load the entire Module into your modules section plus the code so you could try it if you wish.


Michael WashingtonUser is Offline

Posts:64

10/21/2009 9:18 AM  
Yeah the SilverlightDesktop was designed to load an entire assembly into a window. It is not designed to do anything else. It must not allow it's APP file to be overriden because that is te "app domain" that controls the security.

Perhaps SilverlightDesktop wont work for you?
Alex MasitaUser is Offline

Posts:4

10/21/2009 9:27 AM  
Thanks alot Michael,

Would you recommend to another Dnn Silverlight solution that could solve my problem. I still think that you SLD will work because it does the navigation and updates and retrieves records perfectly if I do not add any new controls. I would actually do away with the newer controls if I had to but in this instance, I think there is no other inbuilt alternative to the SL Datagrid. I need to use the Datagrid and I feel there should be a way I could load the Datagrid within DNN Silverlight Desktop. It seems like it only needs a small work around!

Alex
Michael WashingtonUser is Offline

Posts:64

10/21/2009 9:42 AM  
Silverlight will work for you but SilverlightDesktop is designed to work a certain way.

I don't see it as a good fit in the case.
Alex MasitaUser is Offline

Posts:4

10/21/2009 9:54 AM  
Well, thank you very much anyway.

Kind regards.
Michael WashingtonUser is Offline

Posts:64

10/21/2009 9:55 AM  
You can find a bunch of DotNetNuke Silverlight examples here:
http://dnnsilverlight.adefwebserver.com/
You are not authorized to post a reply.
Forums > Silverlight Desktop > Module Development > Hi.....Problem using page switch Method in SLD



ActiveForums 3.7

ActiveForums

ActiveForums

Terms Of Use | Privacy Statement | Copyright 2008 by SilverlightDesktop.net Dynnamite DotNetNuke Skins & Modules