如何访问自定义ListBox模板中的控件?

时间:2013-11-30 22:29:16

标签: xaml windows-phone-7 templates items

我只是想知道是否有人可以帮助我从自定义ListboxItemTemplate访问控件?在这种情况下,图像名为Remove

ListBoxItemTemplate的我的XAML是:

<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 个答案:

答案 0 :(得分:0)

你点击事件是不是被触发了?

1)尝试将Image的Canvas.ZIndex设置为100可以说,只是为了测试是否有任何东西覆盖你的图片。

2)尝试在代码中手动添加事件:

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