1
私はUWPでプレイリスト管理アプリケーションを作っています。私が設定したリストビューのアイテムについて、いくつかの操作を行う必要があります。私はlistitemsにボタンをつけましたが、ボタンのイベントハンドラで "親" listitemを参照する方法はわかりません。例えばボタンがlistitemに置かれ、button eventhandlerでlistitemにアクセスする方法は?
:
ページのリソース:
<DataTemplate x:DataType="data:JonPlaylist" x:Key="PlaylistDataTemplate">
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Name:" Foreground="Azure" VerticalAlignment="Bottom" HorizontalAlignment="Left" FontStyle="Italic" Margin="0,0,10,0"/>
<Button Name="DeletePlayListButton" Content="Delete" Foreground="Azure" Background="SteelBlue" BorderBrush="Azure" Click="DeletePlayListButton_Click"/>
</StackPanel>
</StackPanel>
</DataTemplate>
リストビュー:(それは適切でない可能性がありますalthought。)
<ListView Name="PlayListView" ItemsSource="{x:Bind Playlists}"
IsItemClickEnabled="True"
ItemClick="PlayListView_ItemClick"
ItemTemplate="{StaticResource PlaylistDataTemplate}"
Visibility="Collapsed"
Height="420"
ScrollViewer.VerticalScrollBarVisibility="Visible"/>
そしてdeletebuttonためのイベントハンドラ。これは私が立ち往生した場所で、クリックされたボタンが位置していたリスト項目を参照したい。
private void DeletePlayListButton_Click(object sender, RoutedEventArgs e)
{
?????
}
バインドされたアイテムまたはビジュアルツリーのアイテム、つまりSelectorItemを取得したいですか? –