2015-02-07 44 views
0

我的XAML代碼是如何在Silverlight中使用C#在DataTemplate中的值中獲取ComboBox的選定值?

<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

海峽ing SelectedValue =((BulkEmailNew.BulkEmailService.TemplateCategory)(ComboBoxTemplateCategory.SelectedItem))。TemplateName;

相關問題