0

奇妙な問題があります。グリッド内に配置された ListView を中央揃えにするために知っているすべてのトリックを試しました。どう見ても左寄せですね。ListView の幅と高さはデータ バインドされています。(幅は 350 または 700 の値を取ることができ、高さはサイズ設定に応じて 100 または 200 を取ることができます。サイズ設定がコンパクトな場合は 350x100、通常の場合は 700x200 にする必要があります)。

これはxamlコードです

<Grid x:Name="GridPageLVPortrait" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Background="Beige" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,0,584.714,0" Width="781">
   <ListView x:Name="PageLVPortrait" ItemsSource="{Binding}" CanReorderItems="True" AllowDrop="True" HorizontalAlignment="Center" SelectionMode="Single" IsSwipeEnabled="True" IsItemClickEnabled="True" SelectionChanged="PageLVPortraitSelectionChanged" ItemClick="PageLVPortraitItemClick" Height="{Binding TemplateHeight}" Width="{Binding TemplateWidth}" >
        <ListView.ItemTemplate>
             <DataTemplate>
                 <Canvas HorizontalAlignment="Center" Width="{Binding TemplateWidth}" Height="{Binding TemplateHeight}">
                     <Canvas.Background>
                          <ImageBrush ImageSource="{Binding PageBackground}"/>
                     </Canvas.Background>
                     <Image HorizontalAlignment="Center" Height="{Binding TemplateHeight}" Width="{Binding TemplateWidth}" Source="{Binding Page}" Stretch="None" Opacity="1" CacheMode="BitmapCache" />

                     <StackPanel x:Name="EditDeleteStackPanel" Width="{Binding TemplateWidth}" Height="{Binding TemplateHeight}" Opacity="0.95">
                         <Button x:Name="NoteDelete"  HorizontalAlignment="Right"   VerticalAlignment="Top" Foreground="{x:Null}" Tapped="NoteDelete_Tapped" MinWidth="50" MinHeight="50" Margin="0,0,10,0" BorderBrush="{x:Null}" >
                            <Button.Background>
                                <ImageBrush ImageSource="{Binding Delete}"/>
                            </Button.Background>
                         </Button>
                         <Button x:Name="NoteEdit"  HorizontalAlignment="Right"   VerticalAlignment="Top"   FontFamily="Segoe Script" FontSize="24" BorderBrush="{x:Null}" Tapped="NoteEdit_Tapped" Foreground="{x:Null}" MinWidth="50" MinHeight="50" Margin="0,0,10,0">
                            <Button.Background>
                                <ImageBrush ImageSource="{Binding Edit}"/>
                            </Button.Background>
                         </Button>                             
                     </StackPanel>
                 </Canvas>
             </DataTemplate>
        </ListView.ItemTemplate>
   </ListView>
</Grid>

誰かが親切に助けてくれますか?

4

2 に答える 2

0

私は問題を見つけました。これは、メイン グリッドが 4 つの列に分割されているためです。これは columnspan を使用しているため、配置がめちゃくちゃになります。

于 2013-07-12T09:52:35.397 に答える