开发者

Detect which element scrollbars belong to

I have a relatively complex layout. It consists of: A grid with one column and three rows. In the 开发者_Go百科first row (the on giving me trouble) I have a developer express componenet - another GridControl.

My problem is, that though the height of this first row is Auto, the vertical scrollbar displays even though there's space enough for content.

I've tried setting the ScrollViewer.VerticalScrollBarVisibility="Hidden" on the row's rowdefinition, but this doesn't help.

Likewise, I've set the inner GridControl to not use scrollbars (using some Developer Express magic - not just ScrollViewer as this doesn't work)

Yet, no matter what I do, that damn scrollbar appears... Is there any way to figure out which control renders it, so I can disable the damn thing? It's not just a question of it being ugly - scrolling it actually messes with the layout!

Thanks in advance!

The relevant code:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" ScrollViewer.VerticalScrollBarVisibility="Hidden" />
        <RowDefinition Height="*" MaxHeight="240" />
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <dxg:GridControl Name="StudySizeGrid" Grid.Column="0" Grid.Row="0" >
        <dxg:GridControl.Resources>
            <ControlTemplate x:Key="{dxgt:TableViewThemeKey ResourceKey=ControlTemplate}">
                <ScrollViewer x:Name="scr" 
          VerticalScrollBarVisibility="Disabled" 
          HorizontalScrollBarVisibility="Disabled"
          Focusable="False"
          dxg:GridControl.CurrentView="{Binding RelativeSource={RelativeSource TemplatedParent}}"
          Template="{DynamicResource {dxgt:TableViewThemeKey ResourceKey=ScrollViewerTemplate}}">
                    <ScrollViewer.CanContentScroll>False</ScrollViewer.CanContentScroll>
                </ScrollViewer>
            </ControlTemplate>
        </dxg:GridControl.Resources>
...
</dxg:GridControl>

EDIT FOR CLARIFICATION: This is WPF issue :-)


You could try checking out the VisualTree, i think Snoop might be helpful for that, it probably has some other useful features too. Getting the VisualTree is a trivial matter though, you can write a single recursive method using the VisualTreeHelper, so you might not need the big guns.

e.g.

public static TreeViewItem GetVisualTree(this DependencyObject dpo)
{
    TreeViewItem item = new TreeViewItem();
    item.Header = dpo.GetType().ToString().Split('.').Last();
    if (dpo is FrameworkElement && (dpo as FrameworkElement).Name != string.Empty) item.Header += " (" + (dpo as FrameworkElement).Name + ")";
    int cCount = VisualTreeHelper.GetChildrenCount(dpo);
    for (int i = 0; i < cCount; i++)
    {
        item.Items.Add(VisualTreeHelper.GetChild(dpo, i).GetVisualTree());
    }
    return item;
}

Wrote that quite some time ago, it's very sketchy (wouldn't recommend making it an extension method), gets the whole tree at one, could be modified to only fetch children on expansion of the node.


You could use something like Google Chrome's tools.

I would, in Chrome, right click around the area that has the scroll bars and select "Inspect Element". Chrome will highlight with a border what element you are looking at. You can then navigate the html within Google Chrome's inspector until it is highlighting the element with the scrollbar.

You can then find the reason from there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜