【发布时间】:2016-10-29 19:47:29
【问题描述】:
每当我尝试从组合框中获取文本时,它都会提取像 System.Windows.Controls.ComboBoxItem: Abc 这样的数据
我怎样才能只得到 "Abc" ?我的意思是只说值而不是整个堆栈跟踪。 我的代码看起来像:-
XAML:-
<StackPanel Orientation="Horizontal" Width="auto" HorizontalAlignment="Center" Margin="0,10,0,0">
<TextBlock HorizontalAlignment="Left" FontFamily="/Vegomart;component/Images/#My type of font" Text="User Type:- " FontSize="18" Foreground="Black"/>
<ComboBox x:Name="userType" HorizontalAlignment="Right" FontFamily="/Vegomart;component/Images/#My type of font" Width="170" FontSize="18" Foreground="Black" Margin="40,0,0,0" >
<ComboBoxItem> Abc</ComboBoxItem>
</ComboBox>
</StackPanel>
C#:-
string value = userType.SelectedItem.ToString();
System.Diagnostics.Debug.WriteLine(value);
您的努力将不胜感激:)。
谢谢,
【问题讨论】: