我的XAML代码是
<ComboBox x:Name="ComboBoxTemplateCategory" Grid.Column="3" Grid.Row="2" SelectedValuePath="Text" ItemsSource="{Binding}" >
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5,0,0,0" Text="{Binding Path=TemplateName}" Width="100"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
和
C#代码
string mySelectedValue = ((TextBlock)((ComboBoxItem)
ComboBoxTemplateCategory.SelectedItem).Content).Text;
不工作..
答案 0 :(得分:0)
string SelectedValue =((BulkEmailNew.BulkEmailService.TemplateCategory)(ComboBoxTemplateCategory.SelectedItem))。TemplateName;