Windows runtime 如何在Windows中获取选定项:UI::Xaml::Controls::ComboBox(WinRT)

Windows runtime 如何在Windows中获取选定项:UI::Xaml::Controls::ComboBox(WinRT),windows-runtime,Windows Runtime,我已在组合框中添加了项。如果在组合框中选择了某些项,则无法检索所选项 大多数combox属性都返回对象类型,如果我尝试对对象执行ToString(),它将返回奇怪的值 我试过这些属性 MainPage::cmbDeviceList_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e){ auto str = cmbDeviceList

我已在组合框中添加了项。如果在组合框中选择了某些项,则无法检索所选项

大多数combox属性都返回对象类型,如果我尝试对对象执行ToString(),它将返回奇怪的值

我试过这些属性

 MainPage::cmbDeviceList_SelectionChanged(Platform::Object^ sender,      Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e){
 auto str = cmbDeviceList->SelectedItem->ToString;
 auto str1 = cmbDeviceList->SelectedValue->ToString();
 }    
我的问题是

  • 如何在用户选择时从组合框中检索项目
  • 为什么大多数属性返回对象。保留对象的目的是允许开发人员插入类结构吗 最后我得到了答案

    应该是

     auto str = (String^) cmbDeviceList->SelectedItem;
    
    但仍不清楚为什么会这样