2012-06-08 2 views
1
<Window 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" 
x:Class="Trainning.biding" 
x:Name="Window" 
Title="biding" 
Width="640" Height="480"> 
<Window.Resources> 
    <Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"> 
     <Setter Property="Background" Value="Transparent"/> 
     <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/> 
     <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/> 
     <Setter Property="Padding" Value="2,0,0,0"/> 
    </Style> 
</Window.Resources> 
<Grid Margin="8,8,0,8" DataContext="{Binding Source={StaticResource kirupaZuneDataSampleDataSource}}"> 
    <ComboBox x:Name="comboBox" Height="48" Margin="99,83,0,0" VerticalAlignment="Top" SelectedIndex="0" HorizontalAlignment="Left" Width="96"> 
     <ComboBoxItem Content="#FF13428D"/> 
     <ComboBoxItem Content="#00FFFFFF" Background="#00166A13"/> 
     <ComboBoxItem Content="#FF890E6F" Background="#0005116E"/> 
     <ComboBoxItem Content="#0005116E" Background="#0009683A"/> 
     <ComboBoxItem Content="##0009683A"/> 
    </ComboBox> 
    <TextBox Margin="99,145,297,0" TextWrapping="Wrap" Text="{Binding SelectedItem, ElementName=comboBox}" Height="41" VerticalAlignment="Top"/> 
</Grid> 

вопрос в элементе связывания

это выход будет как на рисунке ниже

element_binding

, но именно мне нужно, чтобы связать строку «# FF13428D» в текстовое поле.

что я должен сделать для этого ... пожалуйста, помогите мне ..

ответ

4

Использование

Text="{Binding SelectedItem.Content, ElementName=comboBox}" 

для доступа к содержимому выбранного элемента ComboBox.

Смежные вопросы