How do I access a control inside a custom ListBox template?

63 Views Asked by At

I was just wondering if there is anyone who could help me with accessing a control from a custom ListboxItemTemplate? in this case the image called Remove

My XAML for the ListBoxItemTemplate is:

<StackPanel x:Name="stk" toolkit:TiltEffect.IsTiltEnabled = "true" HorizontalAlignment="Left" VerticalAlignment="Top" Height="82" Width="462">
    <toolkit:ContextMenuService.ContextMenu>
        <toolkit:ContextMenu IsZoomEnabled="True" x:Name="menu11">
            <toolkit:MenuItem Header="Share..."  Click="Sharente_Click" FontFamily="Segoe WP SemiLight" Background="Transparent" BorderBrush="Black"/>
            <toolkit:MenuItem x:Name="pt" Header="Pin to start"  Click="PinToStart_Click" FontFamily="Segoe WP SemiLight" Background="Transparent" BorderBrush="Black"/>
            <toolkit:MenuItem Header="Delete note"  Click="Delete_Click" FontFamily="Segoe WP SemiLight" Background="Transparent" BorderBrush="Black"/>
        </toolkit:ContextMenu>
    </toolkit:ContextMenuService.ContextMenu>
    <ScrollViewer x:Name="scroller" HorizontalAlignment="Left" Height="69" Margin="1,1,0,0" VerticalAlignment="Top" Width="369" VerticalScrollBarVisibility="Disabled"
        HorizontalScrollBarVisibility="Hidden" >
        <TextBlock Loaded="NoteName_Loaded" x:Name="NoteName" TextWrapping="NoWrap" Text="{Binding FileNameX}" FontSize="38.667" FontFamily="Segoe WP SemiLight" Height="54" Margin="0,-30,0,0">
            <TextBlock.Foreground>
                <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
            </TextBlock.Foreground>
        </TextBlock>
    </ScrollViewer>
    <TextBlock x:Name="Description" Height="37" TextWrapping="NoWrap" Text="{Binding Description}" FontSize="24" FontFamily="Segoe WP" HorizontalAlignment="Left" Width="379" Margin="3,-29,0,8" VerticalAlignment="Top" Opacity="0.85" Foreground="#FF787878"/>
    <TextBlock x:Name="ClickArea" Height="79" TextWrapping="Wrap" Margin="0,-73,0,0"/>
    <TextBlock x:Name="TimeDate" HorizontalAlignment="Right" Height="37" Margin="0,-130,0,0" TextWrapping="Wrap" Text="{Binding FileTime}" Width="76" Foreground="#FF7C7C7C" FontSize="22.667"/>
    <Image x:Name="Remove" toolkit:TiltEffect.IsTiltEnabled = "True" HorizontalAlignment="Right" Height="48" Margin="0,-70,12,0" Source="/icons/appbar.delete.rest.png" Stretch="Fill" Width="48" Tap="Remove_Tap"/>
</StackPanel>
1

There are 1 best solutions below

0
On

And you tap event isn't triggered?

1) Try to set Canvas.ZIndex of Image to 100 lets say, just to test if nothing is overcovering you'r picture.

2) Try to add event manualy in code:

 Remove.Tapped +=(s,e) =>{ //TODO: CODE };