views:

7

answers:

0

I am trying to change the visibility of a control in a ListBoxItem template (based on it beeing selected in the parent listbox) through a ChangePropertyAction but the code below does not work. I tried fiddling around with setting the TargetName on the trigger or setting the default visibility of the control through a style. I debugged the Binding through a DebugConvert and checked that the IsSelected is correctly set to true but it still does not work. Can anybody explain to me why this is not working and how I can fix this?

<ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="{Binding PersonalData.LastName}" FontSize="20" FontWeight="Bold"  Grid.Column="0"/>
                                <TextBlock FontSize="20" Text="{Binding PersonalData.FirstName}" Grid.Column="1" />
                                <StackPanel x:Name="buttonStackPanel" Orientation="Horizontal" Grid.Column="2" Visibility="Collapsed">
                                    <Interactivity:Interaction.Triggers>
                                        <ei:DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}, Path=IsSelected, Converter={StaticResource DebugConverter}}">
                                            <ei:ChangePropertyAction PropertyName="Visibility">
                                                <ei:ChangePropertyAction.Value>
                                                    <Visibility>Visible</Visibility>
                                                </ei:ChangePropertyAction.Value>
                                            </ei:ChangePropertyAction>
                                        </ei:DataTrigger>
                                    </Interactivity:Interaction.Triggers>
                                    <Button Content="Do Something"></Button>
                                </StackPanel>
                            </Grid>
[...]