【问题标题】:border that encapsulates textblocks封装文本块的边框
【发布时间】:2018-02-28 03:10:20
【问题描述】:

我不确定这在 wpf 中是否可行,但假设我在页面上的网格中有多个文本块和其他控件

<TextBlock Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="1"  FontSize="30" 
Text="Station" HorizontalAlignment="Left" Margin="65.2,0,0,3"  
VerticalAlignment="top" Width="104" Height="47" />
    <ComboBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="1" 
HorizontalAlignment="Left" Margin="50.2,2,0,0"  VerticalAlignment="Bottom" 
Width="120" Height="22" />
    <TextBlock Grid.Row="2" Grid.Column="4" Text="Date"  FontSize="30" 
HorizontalAlignment="Left" Margin="59.8,0,0,5"  VerticalAlignment="top" 
Height="45" Width="72" />
    <DatePicker Grid.Row="2" Grid.Column="4" HorizontalAlignment="Left" 
Margin="59.8,0,0,0" VerticalAlignment="Bottom"  
RenderTransformOrigin="1.078,0.417" Height="24" Width="102" />
    <TextBlock Grid.Row="3" Grid.Column="0" Text="Item"  FontSize="30" 
HorizontalAlignment="Left" Margin="59.8,0,0,5"  VerticalAlignment="top" 
Height="45" Width="72" />
    <TextBlock Grid.Row="3" Grid.Column="1" Text="UoM" FontSize="30" 
HorizontalAlignment="Left" Margin="59.8,0,0,5" VerticalAlignment="top" 
Height="45" Width="72" />
... 

有没有办法封装这些控件并将它们放在我屏幕顶部的边框中,即使代码下方的文本框向下滚动也是如此。即类似于当您向下滚动页面的其余部分时停留在屏幕顶部的 HTML 标题?

【问题讨论】:

    标签: wpf


    【解决方案1】:

    我会为底部的控件使用滚动查看器,并让网格负责静态定位。

    类似

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Border>
            <!-- Your static header here -->
        </Border>
        <ScrollViewer Grid.Row="1">
            <StackPanel>
                <!-- Your scrolling content here -->
            </StackPanel>
        </ScrollViewer>
    </Grid>
    

    【讨论】:

      猜你喜欢
      • 2012-10-23
      • 2011-02-17
      • 1970-01-01
      • 1970-01-01
      • 2013-01-12
      • 1970-01-01
      • 1970-01-01
      • 2015-11-24
      • 1970-01-01
      相关资源
      最近更新 更多