結局欲しいもの
同じ外観 (素晴らしいコントロール) を持つアイテムのテーブルですが、次のように異なるテキストが表示されますが、それ以上のものがあります。
_ 3 6
1 4 7
2 5 8
_ _ 9
「_」は何もありません。
私が持っているもの
gridView の境界線を使用した非常に単純な例があり、GridView.ItemTemplate の項目間にスペースがある理由がわかりませんか? ItemHeightとItemWidthに大きな値を設定すると、すべて問題ありません(境界線のフルサイズが表示されます)が、この場合、アイテム間に
さらに大きなスペースがあり
ます<VariableSizedWrapGrid Orientation="Vertical" Margin="0" ItemHeight="
" ItemWidth="
" />
私の例の完全なコード
class SomeData
{
public SomeData(int i)
{
Number = i;
}
public int Number { get; set; }
}
class SomeModel
{
public SomeModel(int key)
{
Key = key.ToString();
Items = new List<SomeData>();
}
public string Key { get; set; }
public List<SomeData> Items { get; set; }
}
class ItemPanelVM : BindableBase
{
public ItemPanelVM()
{
var list = new List<SomeModel>();
for (int i = 0; i < 10; i++)
{
list.Add(new SomeModel(i));
for (int j = 0; j < 10; j++)
{
list[i].Items.Add(new SomeData(j));
}
}
SomeGroup = list;
}
private List<SomeModel> _someModels;
public List<SomeModel> SomeGroup
{
get { return _someModels; }
set
{
_someModels = value;
OnPropertyChanged();
}
}
}
および xaml スニペット
<UserControl.Resources>
<CollectionViewSource
x:Key="simpleViewSource"
IsSourceGrouped="True"
Source="{Binding SomeGroup}"
ItemsPath="Items"
d:Source="{Binding SomeGroup, Source={d:DesignInstance Type=test:ItemPanelVM, IsDesignTimeCreatable=True}}"/>
</UserControl.Resources>
<Grid DataContext="{Binding}">
<GridView SelectionMode="None" IsItemClickEnabled="False"
ItemsSource="{Binding Source={StaticResource simpleViewSource}}"
HorizontalAlignment="Left"
Margin="0">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Margin="0" >
<TextBlock Text="{Binding Key}" />
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid Orientation="Vertical" Margin="0"
ItemHeight="30" ItemWidth="30" />
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
<GridView.ItemTemplate>
<DataTemplate>
<Grid>
<Border DataContext="{Binding}" Margin="0" Background="Pink" BorderThickness="2" BorderBrush="Brown" Height="30" Width="30">
<TextBlock Text="{Binding Number}" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center"/>
</Border>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</Grid>
結果
スクリーンショット
質問
なんで?これらのスペースはどこから来たのですか? どうしたらいいのかわからないという話ではありません。何が起こっているのかわからないということです。
PS Google翻訳へのすべての苦情。