Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Normally below code will result in X:Infinity, Y:Infinity

TouchCollection touchState = TouchPanel.GetState();

foreach (TouchLocation t in touchState)
    if (t.State == TouchLocationState.Pressed)
        vb.ButtonTouched((int)t.Position.X, (int)t.Position.Y);

Then, I followed this and added below code at the first line in update method. (I still don't know how it's worked, but it fixed the problem)

if (_firstUpdate)
    typeof(Microsoft.Xna.Framework.Input.Touch.TouchPanel).GetField("_touchScale",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).SetValue(null, Vector2.One);
    _firstUpdate = false;

And then, when I randomly testing something, there are several area that won't read the user touch.

The actual screenshoot

The tile with the purple dude is the area which won't receive user input (It don't even detect "Pressed", the TouchCollection.Count = 0)

Any idea how to fix this?

UPDATE 1 : The second attempt in recompiling

enter image description here

The difference is weird. Dunno why the consistent clickable area is just 2/3 area to the left

UPDATE 2 : After trying to rotate to landscape and back to portrait to randomly testing, then the outcome become :

enter image description here

share|improve this question
Are you able to test on a real device? It's possible the emulation is flawed. (Though you clearly have code problems as well.) – Seth Battin Jun 1 '13 at 16:51
I'm afraid not. I don't own WP8 yet. My teacher tries the code above in monogame non-WP8 and it worked well. I think the problem is because the ClientBound is invalid. But I doesn't know how to fix it. – Moses Aprico Jun 1 '13 at 18:15
Did you solve the issue of certain areas not responding to touch? I am still having this problem. – dChimento Nov 7 '13 at 20:19
I've post an answer to this, just now. EDIT : Ouch sorry I answered wrong problem. I'll fix it – Moses Aprico Nov 9 '13 at 2:55
I've posted the correct one recently – Moses Aprico Nov 9 '13 at 3:48
up vote 0 down vote accepted

There are 3 changes I made to solve this :

1) Make some changes in GamePage.xaml.

2) Using the different way to use TouchPanel.

3) Using the monogame-develop source code as my project reference instead of the installed one (3.0.1).


1) Make some changes in GamePage.xaml

Normally, when you are first created a monogame project, there are these codes in the GamePage.xaml.

<DrawingSurfaceBackgroundGrid x:Name="XnaSurface" Background="Transparent">
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>

    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
        <TextBlock Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">


....Change it into :

<Grid x:Name="LayoutRoot">
    <MediaElement />
    <DrawingSurface x:Name="XnaSurface" />

2) Using the different way to use TouchPanel.

First step, is to add enabled gestures you want in your game. Set it in your Game1.cs constructor (TouchPanel.EnabledGestures)

    _graphics = new GraphicsDeviceManager(this);
    Content.RootDirectory = "Content";
    TouchPanel.EnabledGestures = GestureType.FreeDrag | GestureType.Tap;

You can add in extra enabled gestures by adding | Gesture.DoubleTap (for example), etc.

Second step is to use below code to detect your touch (put it in your update method)

public override void Update(GameTime gameTime)
    while (TouchPanel.IsGestureAvailable)
        GestureSample gesture = TouchPanel.ReadGesture();
        switch (gesture.GestureType)
            case GestureType.Tap:
                //what to do if a tap is detected??
            case GestureType.FreeDrag:
                //what to do if a freedrag is detected??
            //and so on, depends on your enabledgestures..

3) Using the monogame-develop source code as my project reference instead of the installed one (3.0.1).

There is some bugs in MonoGame 3.0.1, so after I read & asked several times at the monogame forum, it's said that the "developed" monogame source code, is already corrected some problems (including mine). But since they hasn't released the "install" version, I need to use it directly from the source code. This is how :

That's my question thread, and it already answered (and solved) clearly.


Hope those helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.