我第一次为摩托罗拉 MC75 设备编写 Windows Mobile 6.5 应用程序。
我为每个屏幕使用 UserControls,并且使用单个“HomeForm”,我面临的问题是:-
- 设备上没有关闭按钮。
- 没有键盘(输入面板)虽然我已经在文本框上使用 InputPanel 编写了代码,但它没有工作。
在模拟器上,关闭按钮和键盘面板都会显示。
以下是我用来设置新 UserControl 并显示的代码:
public static HomeForm HomeFormGet(string ControlName, object viewModel)
{
if (homeForm == null)
{
homeForm = new HomeForm();
}
BaseUserControl prevUserControl = homeForm.ActiveUserControl;
homeForm.ActiveUserControl = getUserControl(ControlName, homeForm);
if (viewModel != null)
{
homeForm.ActiveUserControl.Model = viewModel;
}
homeForm.ActiveUserControl.DBName = DBName;
homeForm.ActiveUserControl.UserName = UserName;
if (!string.IsNullOrEmpty(homeForm.ActiveUserControl.PrevUserControlName) && homeForm.activeUserControl.PrevUserControlName == prevUserControl.Name)
{
homeForm.activeUserControl.PrevUserControl = prevUserControl;
}
else
{
foreach (UserControl uCtl in controlsCache)
{
if (homeForm.activeUserControl.PrevUserControlName == uCtl.Name)
{
homeForm.activeUserControl.PrevUserControl = (BaseUserControl)uCtl;
break;
}
}
}
homeForm.ActiveUserControl.Location = new Point(0, 0);
//homeForm.activeUserControl.Size = new Size(homeForm.Width, homeForm.activeUserControl.Height);
//homeForm.activeUserControl.Dock = DockStyle.Fill;
homeForm.AutoScroll = true;
homeForm.ActiveUserControl.Show();
return homeForm;
}