我在我的Windows应用程序中使用了一个ComboBox
,用于允许用户选择时间。
XAML
<ComboBox Name="timePeriodComboBox"
HorizontalContentAlignment="Left"
Width="200" Height="60"
FontSize="30"
HorizontalAlignment="Center" VerticalAlignment="Top"
Grid.Column="2">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
C#
#region Initializing Frequency Combo Box
timePeriodComboBox.Items.Add("1 hour");
timePeriodComboBox.Items.Add("2 hours");
timePeriodComboBox.Items.Add("5 hours");
timePeriodComboBox.Items.Add("10 hours");
timePeriodComboBox.Items.Add("15 hours");
timePeriodComboBox.Items.Add("20 hours");
timePeriodComboBox.Items.Add("24 hours");
timePeriodComboBox.Items.Add("48 hours");
timePeriodComboBox.Items.Add("72 hours");
timePeriodComboBox.Items.Add("96 hours");
timePeriodComboBox.SelectedIndex = 0;
timePeriodComboBox.SelectionChanged += timePeriodComboBox_indexChanged;
#endregion
historyRequestModel.time = timePeriodComboBox.SelectedItem.ToString().Split(' ')[0];
当我在一台惠普Windows平板电脑上运行应用程序时,我的列表中的第一个项目(1小时)不能被点击或选择,甚至无法高亮显示,而其他项目可以正常选择。
但是,当我在Visual Studios的模拟器上运行时,它可以正常工作。可是其他项目则是可选择的。
有人能告诉我出了什么问题吗?是我做错了什么还是这是一个错误?老实说,我认为问题可能是本地机器使用鼠标和点击作为交互,而平板电脑使用触摸屏作为交互。这只是一个猜测,但我曾经在组合框的旋转木马版本上遇到过类似的问题。在本地机器上运行良好,但在平板电脑上却不断复制值。所以我把旋转关闭了。你有什么想法吗?
timePeriodComboBox_indexChanged
事件处理程序。"不能选择"的含义是指在某个特定的上下文中,用户无法从一组选项中选择任何一个。timePeriodComboBox_indexChanged
事件处理程序是与时间段选择下拉框相关联的函数,当用户更改时间段选择时会触发该事件处理程序。 - CodeCastertimePeriodComboBox.SelectedIndex = 0
)。如果你无法“选择”这个项目,那么你可能会遇到某种编译错误。它会认为CodeCaster的评论是最重要的,显示你的indexChanged
事件。 - KSdevtimePeriodComboBox_indexChanged
的实现在哪里?请展示一下。 - Fedor