我在让 VariableSizedWrapGrid 水平换行时遇到问题。我所能得到的似乎只是我的元素垂直堆叠在一个列中。我不确定我错过了什么。
理想情况下,我希望有 3 列输入字段。字段的数量会根据所选的表而变化,因此它们只需要包装即可。
<ScrollViewer
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<VariableSizedWrapGrid
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Orientation="Horizontal">
<ItemsControl
ItemsSource="{x:Bind ViewModel.CurrentRow.Values}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="models:RowValue">
<Grid Width="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Text="{x:Bind key.ColumnValidation.column_label}"
Margin="0"
Padding="0"
Grid.Column="0">
</TextBlock>
<TextBox
Grid.Column="1"
Visibility="{x:Bind vm:Converters.IsTextBoxField(key.ColumnValidation.data_type)}"
Text="{x:Bind value}">
</TextBox>
<RichTextBlock
Visibility="{x:Bind vm:Converters.IsHyperlinkField(key.ColumnValidation.data_type)}">
<Paragraph>
<Span>
<Hyperlink />
</Span>
</Paragraph>
</RichTextBlock>
<DatePicker
Visibility="{x:Bind vm:Converters.IsDateField(key.ColumnValidation.data_type)}">
</DatePicker>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</VariableSizedWrapGrid>
</ScrollViewer>