監視可能なコレクションから動的に取り込まれているリストボックスにリストボックスアイテムがあり、リストボックスアイテムの「選択済み」イベントに相互作用トリガーを使用してアクションを起動しようとしているので、来るアイテムにバインドできます観察可能なコレクションから。
私が抱えている問題は、イベントトリガーを使用して「選択済み」イベントにアクセスできるように見えることです。
コードは次のとおりです。
<ListBox x:Name="AssocitedLayerListControl" Background="Transparent" BorderBrush="Transparent" ItemContainerStyle="{StaticResource ListBoxItemStyle}"
ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Auto"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="10,0,10,0" Padding="0" Height="25" Width="Auto" >
<!-- Attribute Table Item Template-->
<ListBox.ItemTemplate>
<DataTemplate>
<ContentControl>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0">
<TextBlock Text="{Binding Path=Key}"
Foreground="#FFFFFFFF"
FontSize="10" LineHeight="20"
HorizontalAlignment="Left" VerticalAlignment="Center"
Margin="5,0,5,0" Padding="0" />
<Button BorderBrush="#FFFFFFFF" BorderThickness="1" Background="#FF000000"
HorizontalAlignment="Left" VerticalAlignment="Top"
Padding="1" Margin="0,1,0,1" Style="{StaticResource CloseItemStyle}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<actions:RemoveLayer LayerName="{Binding Path=Key}" TargetGraphicsLayer="{Binding Path=Value}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Selected" SourceObject="{Binding RelativeSource={RelativeSource Mode=TemplatedParent, AncestorType=ListBoxItem}}">
<actions:SetGraphicLayerInGrid LayerName="{Binding Path=Key}" TargetGraphicsLayer="{Binding Path=Value}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ContentControl>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>