Hub App .... within Hub Sections objects not recognized in code

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

41 Replies - 2326 Views - Last Post: 07 November 2014 - 11:09 PM Rate Topic: -----

#1 javmiller  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 05-May 11

Hub App .... within Hub Sections objects not recognized in code

Posted 14 June 2014 - 08:06 PM

I am working on creating a hub app that has three hub sections. Each hub section looks like this:
<HubSection>
<DataTemplate>
content here...
</DateTemplate>
</HubSection



I have objects that are not being recognized in hub.xaml.vb, it brings up this error: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

I have created other apps from scratch, using Blank app and never had this issue, only with this hub app.
Any ideas?

Is This A Good Question/Topic? 0
  • +

Replies To: Hub App .... within Hub Sections objects not recognized in code

#2 javmiller  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 05-May 11

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 15 June 2014 - 12:16 PM

If anyone is unsure as to what message i am trying to convey, please do ask for clarification. Thanks!
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3838
  • View blog
  • Posts: 13,595
  • Joined: 12-December 12

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 15 June 2014 - 12:43 PM

Well line 4 should be DataTemplate and line 5 isn't finished correctly with '>'. That's all I can advise based on the information you have given.
Was This Post Helpful? 0
  • +
  • -

#4 javmiller  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 05-May 11

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 15 June 2014 - 07:34 PM

I'm sure what you mean by not being finished by a '>'. But I think the problem is with the datatemplate. I even named the hubsection and it's name is recognized in the code, but whatever is within any of the datatemplates is not.
Was This Post Helpful? 0
  • +
  • -

#5 javmiller  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 05-May 11

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 15 June 2014 - 07:59 PM

My situation is similar to this: http://connect.micro...n-item-template where they explain that the controls within the datatemplate are not recognized in the datatemple. I could remove the handles clause and make sure it points to the sub in the xaml, but i need to point to the controls within the codes, but they are not recognized.
Was This Post Helpful? 0
  • +
  • -

#6 torind_2000  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 57
  • View blog
  • Posts: 292
  • Joined: 22-August 11

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 16 June 2014 - 10:49 AM

View Postjavmiller, on 15 June 2014 - 10:34 PM, said:

I'm sure what you mean by not being finished by a '>'. But I think the problem is with the datatemplate. I even named the hubsection and it's name is recognized in the code, but whatever is within any of the datatemplates is not.

He means, you didn't close a tag.
Plus you have spelling errors in the bit you originally posted.
Was This Post Helpful? 0
  • +
  • -

#7 javmiller  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 05-May 11

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 16 June 2014 - 05:22 PM

View Posttorind_2000, on 16 June 2014 - 10:49 AM, said:

View Postjavmiller, on 15 June 2014 - 10:34 PM, said:

I'm sure what you mean by not being finished by a '>'. But I think the problem is with the datatemplate. I even named the hubsection and it's name is recognized in the code, but whatever is within any of the datatemplates is not.

He means, you didn't close a tag.
Plus you have spelling errors in the bit you originally posted.

I see. I have all tags closed and those spelling errors are just a spelling error when I made the first post, they are correctly spelled in the code.
Was This Post Helpful? 0
  • +
  • -

#8 torind_2000  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 57
  • View blog
  • Posts: 292
  • Joined: 22-August 11

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 17 June 2014 - 06:22 AM

View Postjavmiller, on 14 June 2014 - 11:06 PM, said:

...Handles clause requires a WithEvents variable defined in the containing type or one of its base types.


This error seems pretty specific, would you please post more of your code?
Was This Post Helpful? 0
  • +
  • -

#9 javmiller  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 05-May 11

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 18 June 2014 - 09:13 PM

View Posttorind_2000, on 17 June 2014 - 06:22 AM, said:

View Postjavmiller, on 14 June 2014 - 11:06 PM, said:

...Handles clause requires a WithEvents variable defined in the containing type or one of its base types.


This error seems pretty specific, would you please post more of your code?


I don't think that is necessary because what it simply means is that any of the controls cannot be accessed within a datatemplate by the vb code. The closest i have gotten is by using Usercontrols. Example:
<Hub>
<HubSection>
<DataTemplate>

<local:UserControl1></local:UserControl1>

</DataTemplate>
</HubSection>
</Hub>


And from the UserControl1 I can acces the buttons and other controls from the code. So the usercontrols work perfectly. But now the issue is controlling controls from usercontrol to usercontrol. I've tried this on usercontrol1 button click:
Private Sub Button1_Click(sender As Object, e As RoutedEventArgs) Handles Button1.Click
        UserControlSec2.Listview1.items.add(Textbox1.Text)
    End Sub

but have issues with is saying that it's private. I then added: x:FieldModifier="public" to the listview and it fixed that error, but now i get the error: "Reference to a non-shared member requires an object reference."

So, now i am stuck with that ...
I hope i have explained what i've done so far clearly enough. Please let me know if any of you don't understand.
Was This Post Helpful? 0
  • +
  • -

#10 Sheepings  Icon User is offline

  • D.I.C Addict

Reputation: 73
  • View blog
  • Posts: 571
  • Joined: 05-December 13

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 19 June 2014 - 05:50 AM

You have to make the method Shared or use an instance of the class its in.

Either try declare it as object, (I don't know what you're doing) but if its a subroutine as Private Member, change it to Shared or Public.
Was This Post Helpful? 0
  • +
  • -

#11 javmiller  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 05-May 11

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 19 June 2014 - 05:47 PM

View PostSheepings, on 19 June 2014 - 05:50 AM, said:

You have to make the method Shared or use an instance of the class its in.

Either try declare it as object, (I don't know what you're doing) but if its a subroutine as Private Member, change it to Shared or Public.

Sorry, I'm not quite sure I understand you correctly. Do you mean to change this:
Private Sub Button1_Click(sender As Object, e As RoutedEventArgs) Handles Button1.Click
        UserControlSec2.Listview1.items.add(textbox1.Text)
    End Sub 

to
Public Sub Button1_Click(sender As Object, e As RoutedEventArgs) Handles Button1.Click
        UserControlSec2.Listview1.items.add(textbox1.Text)
    End Sub 


If so, I have tried this and the error remains ...
Was This Post Helpful? 0
  • +
  • -

#12 javmiller  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 05-May 11

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 19 June 2014 - 06:09 PM

OK, now i tried using this:
Dim sec2 as UserControlSec2
and that got rid of the error, but it crashes upon clicking the button as mentioned in previous codes. So then i tried
Public sec2 as UserControlSec2
, but no difference. I wish i could give you an error message for when it crashes when debugging, but my whole visual studio application crashes, due to a glitch in it somewhere. I would have to re-install it, but i have been putting it off since it takes a long time. Visual Studio seems to work fine until there is an error when debugging, but that's another issue by itself.

But, does anyone have an idea why it would crash with the code i have? I know its hard to determine when it is not producing an error msg, sorry ... (Until i re-install VS ...)
Was This Post Helpful? 0
  • +
  • -

#13 Sheepings  Icon User is offline

  • D.I.C Addict

Reputation: 73
  • View blog
  • Posts: 571
  • Joined: 05-December 13

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 19 June 2014 - 07:00 PM

View Posttorind_2000, on 17 June 2014 - 02:22 PM, said:

...Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

See the quote above. You appear to be trying to access something from another class or instance hence the quote. Adding it should fix your problem. I should have been a bit clearer, declare <Declation - Public, Shared etc> WithEvents <Variable> As <Type>.

Edit: Highlighted what you need to make addition to.

This post has been edited by Sheepings: 19 June 2014 - 07:15 PM

Was This Post Helpful? 0
  • +
  • -

#14 javmiller  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 05-May 11

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 23 June 2014 - 05:10 PM

Sorry for the late reply, i have been busy with other things. Anyways ... I have already figured out how to write the codes without any errors, using a code i have previously posted. But i dont know what the problem is when it fails to execute the code properly when debuging, it errors out, but i'll have to reinstall my copy of Visual Studio in order to give you what the error is, because it just crashes Visual Studio and restarts. So i will get back to you, unless you can figure out what is causing this error.
Was This Post Helpful? 0
  • +
  • -

#15 javmiller  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 05-May 11

Re: Hub App .... within Hub Sections objects not recognized in code

Posted 30 June 2014 - 08:02 PM

Ok, now I've gotten an error code from when it fails to execute the button properly to my liking. Using
Public Sub Button1_Click(sender As Object, e As RoutedEventArgs) Handles Button1.Click
        UserControlSec2.Listview1.items.add(textbox1.Text)
    End Sub 


upon debugging it brings this error: system.NullReferenceException occured. with
Dim sec2 as UserControlSec2

selected.
Anyone have any ideas?
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3