You are invited to Log in or Register a free Frihost Account! WPF usercontrols, parent objects and the...[RESOLVED]

Hi guys,
I'm working on a school project and I'm kind of stuck on something and I was hoping that somebody can point me in the right direction.
this is the situation:
in my MainWindow.xaml I have a grid named maingrid and I use it to load other user controls in it.
these user controls are actualy complete forms which retreive data from my sql server (2008)
basicly when I click on a button in the mainWindow a new instance of this usercontrol is loaded into the grid and the constructor of this usercontrol will know what to do because I've added arguments to it.
one of these controls is named ctrlView and it holds a listbox with a datatemplate and when one of the listboxitems is doubleclicked I need to load another control in my MainGrid.
this listboxItem has an id which matches the ID of an Item that I want to load in a form that will show it's details ( this user control's name is ctrlDetail)
the problem I'm having is that I can't seem to pull that off
I've tried to create a public function and a shared function in the application.xaml.vb, let's call it "loadNewUserControl", but it doesn't let me access the actual window object to call the function.
in application.xaml.vb when I say Me.MainWindow it doesn't give me a handle to the actual window object because when I use Application.MainWindow.LoadUserControl it will tell me that LoadUserControl is not a member of the Window Object.

my question is: is there another way I could try out?
what I want to accomplish is that when i doubleclick that listboxitem in my ctrlView Usercontrol ( loaded into the MainGrid of MainWindow) a function will be called to Load the usercontrol ctrmlDetail with that id as an argument in Maingrid.
I could post some code but the project is HUGE...
I hope this makes sense, I've had a few beers so... Very Happy
I'm not looking for a handout, if anybody can point me in the right direction I'll be more then happy,

EDIT: I got it working like so:

 Public Sub DoubleClickHandler(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
        Dim item = CType(sender, ListBoxItem)

        Dim selectedFile As System.Data.DataRowView = DirectCast(lstViewer.SelectedItem(), System.Data.DataRowView)

        Dim parent = VisualTreeHelper.GetParent(Me)
        While Not (TypeOf parent Is MainWindow)
            parent = VisualTreeHelper.GetParent(parent)
        End While
        TryCast(parent, MainWindow).LoadItemById(CInt(selectedFile.Row("id")))

    End Sub
Related topics
VB.NET school
VB 6 and tutorials
VB.NET and SQL Server
VBA Developing
VB.NET learning
Need or Flash ActionScript Help!
VB.Net Or C#
A confusion with C# and VB.NET...
OMG! without connection to server option?
What is your recommended free decompiler? class as property of another class - FIXED
Reply to topic    Frihost Forum Index -> Scripting -> Others

© 2005-2011 Frihost, forums powered by phpBB.