Answered by:
Touch Input error in simulator of windows 8 app

Question
-
Whenever i tried to run my app in simulator with touch integration it shows an error or break and shows a System.NullReferenceException what to do now plz help meSunday, February 2, 2014 11:36 AM
Answers
-
You didn't give repro steps so I'm not sure if you're looking at the same thing I am. The exception I see in your code is not related to touch and should reproduce anywhere.
In your itemGridView_ItemClick_1 method you create a new button named Header and immediately check its Tag, but since the Header button wasn't initialized with any data the Tag is null and you get a NullReferenceException when you call ToString() on it.
The other problem you have is that you try to set the Tag on the GridView itself, not on the items within the GridView. There isn't an item at that level to bind to, so the Tag on the ItemClick's sender is null and will still give the same error.
I think what you want is to detect the group that is clicked on. You can find this by looking at e.ClickedItem, casting it to your HubPageDataItem, and checking its UniqueId there:
HubPageDataItem ci = e.ClickedItem as HubPageDataItem; Debug.Assert(ci != null,"Item clicked must be a HubPageDataItem"); string group = ci.Group.UniqueId;
--Rob
- Marked as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Saturday, February 8, 2014 3:10 PM
Thursday, February 6, 2014 8:25 PMModerator
All replies
-
Where does the error occur and what is the code king there?
You'll have to debug your app to figure this out.
--Rob
Sunday, February 2, 2014 4:15 PMModerator -
sir, i have tried a lot and i am working on this project from past many days i have given the url of my whole project please run it in a simulator with touch integration and advice me how to remove an error . I will be great thankful to u.
Monday, February 3, 2014 2:03 PM -
https://skydrive.live.com/redir?resid=3BFB42988C3E81B3%21241Monday, February 3, 2014 2:04 PM
-
If you run the application in the debugger what error do you get and where?
If you'd like somebody to look at a minimal repro sample (not your full app) then please post it as a zip file (Windows does not include 7z support) and share a link in your SkyDrive.
--Rob
Monday, February 3, 2014 11:10 PMModerator -
sir as my account is not verified so i can only write text .
here is the link of my project
https://skydrive.live.com/redir?resid=3BFB42988C3E81B3%21469
and the link of the image which show an error
https://skydrive.live.com/redir?resid=3BFB42988C3E81B3%21468
sir please have a look on the app. i will be great thankful to you.
Thursday, February 6, 2014 11:50 AM -
You didn't give repro steps so I'm not sure if you're looking at the same thing I am. The exception I see in your code is not related to touch and should reproduce anywhere.
In your itemGridView_ItemClick_1 method you create a new button named Header and immediately check its Tag, but since the Header button wasn't initialized with any data the Tag is null and you get a NullReferenceException when you call ToString() on it.
The other problem you have is that you try to set the Tag on the GridView itself, not on the items within the GridView. There isn't an item at that level to bind to, so the Tag on the ItemClick's sender is null and will still give the same error.
I think what you want is to detect the group that is clicked on. You can find this by looking at e.ClickedItem, casting it to your HubPageDataItem, and checking its UniqueId there:
HubPageDataItem ci = e.ClickedItem as HubPageDataItem; Debug.Assert(ci != null,"Item clicked must be a HubPageDataItem"); string group = ci.Group.UniqueId;
--Rob
- Marked as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Saturday, February 8, 2014 3:10 PM
Thursday, February 6, 2014 8:25 PMModerator