所以即時通訊使用運動api和通過事件句柄更新的應用程序。問題是我有麻煩讓消息框顯示,我不明白爲什麼。以下基本代碼:使用Windows Phone 8:消息框已停止工作?
public MainPage()
{
InitializeComponent();
MessageBox.Show("welcome"); //box not showing
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
motion = new Motion();
motion.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20);
motion.CurrentValueChanged +=
new EventHandler<SensorReadingEventArgs<MotionReading>> (motion_CurrentValueChanged);
motion.Start();
}
void motion_CurrentValueChanged(object sender, SensorReadingEventArgs<MotionReading> e)
{
Dispatcher.BeginInvoke(() => CurrentValueChanged(e.SensorReading));
}
private void CurrentValueChanged(MotionReading e)
{
Thickness mar = characterMain.Margin;
txtblck1.Text = "Yaw " + e.Attitude.Yaw.ToString() + " Pitch " + e.Attitude.Pitch + " Roll " + e.Attitude.Roll;
mar.Left = hor + (e.Attitude.Roll * 200);
mar.Top = vert + (e.Attitude.Pitch * 200);
characterMain.Margin = mar;
bool col = engine1.CDetection_V1(characterMain.Margin.Left, characterMain.Margin.Top, characterMain.Width, characterMain.Height, BadGuy.Margin.Left, BadGuy.Margin.Top, BadGuy.Width, BadGuy.Height);
if (col == true)
{
MessageBox.Show("hit");//this doesnt
num.Text = "hit"; //this works
}
}
你能檢查這個例子http://sdrv.ms/1c0rRXI嗎? – Romasz
添加到我的代碼和測試,但仍然沒有運氣,謝謝反正隊友 –
正如你已經運行的例子(沒有修改它) - 有MessageBox工作? – Romasz