1

カスタマイズされた ItemTemplate スタイルのリストボックスを使用しています。基本的に、リストボックスの各項目にボタンを付けます。ボタンなしでリストボックスの最後の項目を表示したい。どうすればそれを達成できますか?

.xaml ファイル コードを以下に示します。

     <!-- ListBox to display recordings -->
        <ListBox Name="myListBox" Grid.Row="0"                     
                 HorizontalAlignment="Left" Width="470"
                 ScrollViewer.VerticalScrollBarVisibility="Visible"  
                 ScrollViewer.ManipulationMode="System"
                 SelectionChanged="OnMemosListBoxSelectionChanged">
            <ListBox.ItemTemplate>

                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <Button Grid.Column="0"
                                Grid.Row="0"
                                Grid.RowSpan="3"
                                Padding="0"
                                HorizontalAlignment="Left"
                                VerticalAlignment="top"
                                Height="80"
                                Width="80"
                                Tag="{Binding BindsDirectlyToSource=True}"
                                Click="OnDeleteButtonClick">                                    
                            <Button.Content>
                                <Image Source="/images/delete.png" Margin="0" Width="50" Height="50" />
                            </Button.Content>
                        </Button>

                        <TextBlock Grid.Column="1" 
                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                   Grid.Row="0"
                                   Text="{Binding fileName}"
                                   VerticalAlignment="Center"/>

                        <StackPanel Grid.Column="1" Margin="0,0,0,17"
                                    Grid.Row="1" Height="50" 
                                    Orientation="Horizontal"
                                    VerticalAlignment="Top">

                            <TextBlock FontSize="{StaticResource PhoneFontSizeNormal}" Text="Recorded on " />
                            <TextBlock FontSize="{StaticResource PhoneFontSizeNormal}" Text="{Binding crDate}" />
                            <TextBlock Text="   Duration " />
                            <TextBlock FontSize="{StaticResource PhoneFontSizeNormal}"  Text="{Binding duration}" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>                
        </ListBox> 
4

2 に答える 2

0

ShowButton などのプロパティをすべてのアイテムに追加し、コレクション内の最後のアイテムに対して false (他のすべてのアイテムに対して true) に設定してから、DataTemplate でプロパティが true の場合にのみボタンを表示します。

于 2012-10-22T14:38:39.847 に答える
0

リストの最後の項目にそのボタンが必要ない理由はわかりませんが、longlistselector の ListFooterTemplate を使用できることをお勧めします。

フッター項目を独立させます。

于 2012-10-23T01:37:50.627 に答える