0
3列のグリッド内にビデオファイルを表示するためのxamlを作成しました。私は以下のようにXAMLを使用していますItemsPanelTemplate内のグリッドにRowDefinitionの数を動的にバインド
<ItemsControl Name="icTodoList" Grid.IsSharedSizeScope="True" ItemsSource="{Binding items}" Grid.Row="0" Grid.Column="0" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate >
<Grid x:Name="icTooList" Margin="100,0,100,0" Style="{Binding Path=Style}">
<Grid.ColumnDefinitions>
<!--Whatever I do I can't get the screen to resize and the cols to have the same width-->
<ColumnDefinition Width="Auto" SharedSizeGroup="A" />
<ColumnDefinition Width="Auto" SharedSizeGroup="A" />
<ColumnDefinition Width="Auto" SharedSizeGroup="A" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
</Grid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="40,0,40,30">
<TextBlock HorizontalAlignment="Center" Margin="0,0,0,0">
<Hyperlink TextDecorations="None" NavigateUri="{Binding UriPath}" RequestNavigate="Hyperlink_RequestNavigate"
CommandParameter="{Binding ElementName=myImg}">
<Image Width="120" Height="120" x:Name="myImg" Source="{Binding Source}" Margin="5"/>
</Hyperlink>
</TextBlock>
<TextBlock Margin="0,120,0,0" HorizontalAlignment="Center">
<TextBlock FontSize="20px" Text="{Binding Title}" Foreground="white"></TextBlock>
</TextBlock>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style>
<Style.Setters>
<Setter Property="Grid.Row" Value="{Binding GridRow}" />
<Setter Property="Grid.Column" Value="{Binding GridColumn}" />
</Style.Setters>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
ここ
私はRowDefinitionの数字私はすでに発見した
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
以下のようにRowDefinitionを使用していた
void setaligned()
{
int currentColumn = 0;
int currentRow = 0;
foreach (BindingFilesContent checkBoxItem in items)
{
checkBoxItem.GridColumn = currentColumn;
checkBoxItem.GridRow = currentRow;
if (currentColumn != 2)
{
currentColumn++;
}
else
{
currentRow++;
currentColumn = 0;
}
}
}
以下のようにバックエンドで必要しかし、私は必要グリッドでこのRowDefinitionを動的にバインドします。私は次のもので試したが、私のために働いていない。以下の質問には誰も答えなかった。
How can I dynamically add a RowDefinition to a Grid in an ItemsPanelTemplate?
私はあなたがリンクされ、応答が必要な方だと思い、それに連動添付プロパティへの公式ガイドに従ってください。 – Seididieci
書きたい構文を投稿できますか? – AnjumSKhan
私は書く方法を知らない。私はrowcountに基づいて複数回RowDefinitionを追加する必要がある。 –