2011-12-21 23 views
0

私はリストボックスにコントロールを設定し、コントロールにはテキストボックスとコンボボックスが設定されます。私は、テキストボックスを編集し、コンボで選択するとき、基になるリスト項目を選択する必要があります。カントはソルティオを見つけるようだ。誰でも?リストボックスから選択した項目をユーザコントロール

<ListBox.ItemTemplate> 
     <DataTemplate> 
      <Controls:ComponentEditItem Background="Transparent"/> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 

答えて

0

あなたはそのコントロールのいずれかがフォーカスされたときにListBoxItemの基礎となる選択するEventTriggerを追加することができます。このようなもの:

<ListBox.ItemTemplate> 
    <DataTemplate> 
     <Controls:ComponentEditItem Background="Transparent"> 
      <Controls:ComponentEditItem.Triggers> 
        <EventTrigger RoutedEvent="GotFocus"> 
         <BeginStoryboard> 
          <Storyboard> 
           <BooleanAnimationUsingKeyFrames Duration="00:00:00" Storyboard.Target="{Binding Path=., RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}}" Storyboard.TargetProperty="IsSelected"> 
             <DiscreteBooleanKeyFrame Value="True" /> 
           </BooleanAnimationUsingKeyFrames> 
          </Storyboard> 
         </BeginStoryboard> 
        </EventTrigger> 
      </Controls:ComponentEditItem.Triggers> 
     </Controls:ComponentEditItem> 
    </DataTemplate> 
</ListBox.ItemTemplate> 
関連する問題