我到处搜索,但没有找到任何好的示例或教程。我有一个列表框,并为它制作了一个 ItemTemplate:
XAML:
<ListBox x:Name="LB_Playlist" ScrollViewer.HorizontalScrollBarVisibility="Disabled" HorizontalAlignment="Left" Height="454" Margin="0,23,0,0" VerticalAlignment="Top" Width="264" Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="0" ItemTemplate="{DynamicResource PlayListItem}" ScrollViewer.VerticalScrollBarVisibility="Hidden">
<ListBox.Resources>
<DataTemplate x:Key="PlayListItem">
<Grid d:DesignWidth="127" d:DesignHeight="105" Width="128" Height="128">
<Label x:Name="L_PlayListName" Content="{Binding Path=PlayList_Name}" HorizontalAlignment="Stretch" Margin="16" Width="Auto" Height="Auto" Background="#26000000" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="BankGothic Lt BT"/>
</Grid>
</DataTemplate>
</ListBox.Resources>
</ListBox>
如何使用代码(动态)每次更改 L_PlayListName 内容以不同的名称添加新项目?我需要开一个新课还是什么?我有一个添加新项目的按钮。我怎样才能做到这一点?