0

所以我试图让我的轴平面被绘制在 中ScrollViewer,然后我想进入并在绘制轴的空间上绘制一个信号列表,以便信号在轴的顶部。我认为正确的做法是使用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>
4

2 回答 2

1

Viv 正在编写一个很好的解决方案,但您需要设置Grid.RowSpan="2"元素StackPanel,一切都会正常工作。

<ScrollViewer 
            x:Name="signal_scrollviewer"
            Focusable="False"
            CanContentScroll="False">
          <Grid>
            <wpfExp:SignalGraphAxis 
                                    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" Margin="0 75 0 0">
              <ItemsPresenter />
            </StackPanel>
          </Grid>
        </ScrollViewer>
于 2013-07-09T07:20:14.757 回答
0

所以当我改变这个绑定时:

Height="{Binding ElementName=signal_scrollviewer, Path=ActualHeight}"

绑定Height而不是ActualHeight,它似乎正在工作。我对交互如何导致我看到的内容有点困惑。

于 2013-07-09T18:58:50.583 回答