我没有使用rad控件的经验,但是如果你想要一些不可滚动的东西,把它移出ScrollViewer。这是一般原则。
我在这里给出了三种可能的方法,随着复杂性的增加,但我希望它们至少能帮助您开始工作。
1。
复制第一个元素并在上面显示它
ScrollViewer
:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<ListBox>
<TextBlock Text="First element"/>
<TextBlock Text="Second element"/>
<TextBlock Text="Third element"/>
<TextBlock Text="Forth element"/>
<TextBlock Text="Fifth element"/>
</ListBox>
<!-- Overlay -->
<Border Background="White" VerticalAlignment="Top">
<TextBlock Text="Overlay text. Should be a duplicate of the First Element"
Margin="3, 0"/>
</Border>
</Grid>
</Page>
这种方法有很多缺点。从复制本身开始,到焦点/键盘管理结束。
2。
除第一个元素以外的所有元素都将进入列表。第一个元素是单独的控件:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- First Element -->
<TextBlock Text="First element"
Grid.Row="0"
Margin="4, 0"/>
<!-- List Element -->
<ListBox Grid.Row="1" BorderThickness="0">
<TextBlock Text="Second element"/>
<TextBlock Text="Third element"/>
<TextBlock Text="Forth element"/>
<TextBlock Text="Fifth element"/>
</ListBox>
</Grid>
</Page>
三。
编写自定义控件。
我没提
Adorners
这里,因为它们看起来像是方法1的高级版本。尽管与最后一种方法相结合,它们可能会产生相当好的解决方案…