因此,我试图让我的轴平面在ScrollViewer
中绘制,然后我想进入并绘制轴线空间中的信号列表被绘制,以便信号在轴的顶部。我认为正确的做法是使用ZIndex
,但我必须做错事。如何使控件在grid中正确重叠使用zindex
http://picpaste.com/signalgraph1-HSFHBYOG.JPG
基本上,它看起来像轴是ScrollViewer
大小像我想要的,但随后的StackPanel
被放置,而不是放在75个单位下来像我期望的轴后,。
这是怎么发生的?我怎样才能得到我想要的行为?
<ScrollViewer
x:Name="signal_scrollviewer"
Focusable="False"
CanContentScroll="False">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="75" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<wpfExp:SignalGraphAxis Grid.ZIndex="1"
Grid.Row="0"
Grid.RowSpan="2"
x:Name="signal_axis"
Height="{Binding ElementName=signal_scrollviewer, Path=ActualHeight}"
signal_graph_window_width="{Binding RelativeSource = {RelativeSource AncestorType={x:Type ScrollViewer}}, Path=ActualWidth}"
GraphHeight ="{Binding ElementName=graph_viewer, Path=GraphHeight, Mode=OneWay}"
PenColor="{Binding ElementName=GraphColorPicker, Path=SelectedColor, Mode=OneWay}"
PenWidth="{Binding ElementName=graph_viewer, Path=GraphPenWidth, Mode=OneWay}"
X_Scale="{Binding ElementName=graph_viewer, Path=X_Scale, Mode=OneWay}"
MaxTimeValue="{Binding ElementName=graph_viewer, Path=_SignalDataViewModel.MaxTimeValue, Mode=OneWay}"
/>
<StackPanel Background="Transparent" Grid.ZIndex="2" Grid.Row="1">
<ItemsPresenter />
</StackPanel>
</Grid>
</ScrollViewer>
请勿在网格中使用ZIndex。网格按顺序排列它的子节点,所以如果你只是把你的Axis控件放在xaml的实际内容之前,它将会在轴控件的“顶部”放置实际的内容。哦,这是控制的是在OFC – Viv
同一网格单元,但我想的是只控制重叠的一部分。那可能吗?我希望轴在0排发车,但在第1行的部分将在连续获得书面之上由StackPanel的1 –
星爷尝试设置'Grid.RowSpan =“2”'你的主轴元件。现在,在0行仅轴元素行1两轴元素,你的'StackPanel'存在,并在XAML之前'StackPanel'发生轴向元件但是存在,这将是后面的'StackPanel'第1行中 – Viv