【发布时间】:2014-09-17 06:23:14
【问题描述】:
所以我做了很多研究并尝试了很多人的解决方案,但似乎没有任何效果,我不知道为什么。 我正在尝试在我的 ComboBox 中查找项目的索引:
string Index = programType.Items.IndexOf("Lose Weight").ToString();
索引始终为“-1”,即使肯定有一个项目具有“减肥”的内容/标签:
<ComboBox x:Name="programType" Header="Desired goal:" HorizontalAlignment="Left" Grid.Row="5" Grid.Column="1" Margin="30,0,0,0" Grid.ColumnSpan="2" VerticalAlignment="Top" Width="200" PlaceholderText="Desired Goal">
<ComboBoxItem Content="Lose Weight" Tag="Lose Weight" IsSelected="True" />
<ComboBoxItem Content="Get Healthier" Tag="Get Healthier"/>
<ComboBoxItem Content="Get Stronger" Tag="Get Stronger"/>
<ComboBoxItem Content="Cardio Booster" Tag="Cardio Booster"/>
</ComboBox>
据我所知,它应该可以工作?我一定做错了什么,有什么提示吗?谢谢!
【问题讨论】:
标签: c# xaml winrt-xaml win-universal-app