滚动查看器中的项目控件

时间:2019-04-18 11:11:58

标签: c# wpf

我正在尝试使Scrollviewer内部的Itemscontrol表现为包装面板。即窗口的包装板尺寸及其内容分布在多行上。目前,我只有一行,底部带有滚动条。我的示例使用了一个扩展面板,但即使设置了LastChildFill,它也无法按我的意愿工作。

XAML:

<DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" LastChildFill="True">
    <GroupBox DockPanel.Dock="Top" Grid.Row="0" Header="Options" Margin="3" BorderThickness="2" FontSize="13">
        <Grid Margin="0,-1,0,2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.5*"/>
                <ColumnDefinition Width="0.5*"/>
                <ColumnDefinition Width="0.5*"/>
            </Grid.ColumnDefinitions>
            <CheckBox Grid.Column="1" x:Name="pvUseReference" Margin="5 6 5 5" FlowDirection="RightToLeft" IsChecked="{Binding pvUseReference}" Content="Use Reference" HorizontalAlignment="Center"/>
            <ComboBox Grid.Column="2" x:Name="pvStream" Width="100" Margin="5 3 5 2" IsEditable="False" SelectedValuePath="Content" SelectedValue="{Binding pvSelectedStream}">
                <ComboBoxItem Content="Upstream"/>
                <ComboBoxItem Content="Downstream"/>
                <ComboBoxItem IsSelected="True" Content="Delta CP"/>
            </ComboBox>
        </Grid>
    </GroupBox>
    <ScrollViewer x:Name="scrollViewer" HorizontalAlignment="Left" VerticalAlignment="Top" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" >
        <Grid>
            <Grid.LayoutTransform>
                <TransformGroup>
                    <ScaleTransform x:Name="ScaleTransformer"/>
                </TransformGroup>
            </Grid.LayoutTransform>
            <ItemsControl ItemsSource="{Binding SweepCharts, Mode=TwoWay}" Width="auto" Height="auto">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border BorderThickness="1" BorderBrush="Black" >
                            <StackPanel>
                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                    <TextBlock  Text="{Binding TitlePrefix}"/>
                                    <TextBlock FontWeight="Bold" Foreground="Red" Text="{Binding ActiveAttitude}"/>
                                    <TextBlock  Text="{Binding TitleSuffix}"/>
                                </StackPanel>
                                <Controls:PresVisControl ImagePath="{Binding PresTapImagePath}"  Margin="5" PresTapDataGreen="{Binding lclPresTapDataGreen}" PresTapDataRed="{Binding lclPresTapDataRed}" PresTapDataScale="{Binding lclPresTapDataScale}"/>
                            </StackPanel>
                        </Border>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Grid>
    </ScrollViewer>
</DockPanel>

0 个答案:

没有答案