wpf listbox synchronize scollbars?

M

mp

Hi
Given two listboxes side by side on a wpf form
Trying to think of a way to cause the scroll bar of either to move both
Similar to windiff or winmerge windows where two files can be viewed side by
side and scrolling affects both panes.
thnaks for any ideas
mark
 
P

Peter Duniho

Hi
Given two listboxes side by side on a wpf form
Trying to think of a way to cause the scroll bar of either to move both

I don't think ListBox gives you direct access to the scrollbar.

One possible approach (besides reimplementing ListBox and including that
feature) would be to use a Panel with AutoScroll enabled as the container
for each ListBox, and resize the ListBox as items are added so that the
ListBox itself doesn't actually have scrollbars.

With the Panel, you do get access to the scrolling information, and so
when it changes in one, you can just set the other to be identical.

I haven't tried that myself, but I think it should work.

Pete
 
M

mp

Peter Duniho said:
I don't think ListBox gives you direct access to the scrollbar.

One possible approach (besides reimplementing ListBox and including that
feature) would be to use a Panel with AutoScroll enabled as the container
for each ListBox, and resize the ListBox as items are added so that the
ListBox itself doesn't actually have scrollbars.

With the Panel, you do get access to the scrolling information, and so
when it changes in one, you can just set the other to be identical.

I haven't tried that myself, but I think it should work.

Pete
Thanks will look into that
mark
 
P

Peter Duniho

I don't think ListBox gives you direct access to the scrollbar.

One possible approach (besides reimplementing ListBox and including that
feature) would be to use a Panel with AutoScroll enabled as the
container for each ListBox, and resize the ListBox as items are added so
that the ListBox itself doesn't actually have scrollbars.

With the Panel, you do get access to the scrolling information, and so
when it changes in one, you can just set the other to be identical.

I haven't tried that myself, but I think it should work.

Ah, here's a good example of my comments in the other thread with respect
to Forms versus WPF. I overlooked that your question was specifically
about WPF (trying putting it all caps next time :) ). As far as I know,
in WPF the Panel class doesn't support scrolling. Instead, I think you
want the ScrollViewer class.

Pete
 
G

Geoffrey Summerhayes

Hi
Given two listboxes side by side on a wpf form
Trying to think of a way to cause the scroll bar of either to move both
Similar to windiff or winmerge windows where two files can be viewed sideby
side and scrolling affects both panes.
thnaks for any ideas
mark

I used two ListViews and ScrollIntoView method.
It's not exactly pretty, but it was for a one-off
in-house tool.
 
M

mp

Peter Duniho said:
Ah, here's a good example of my comments in the other thread with respect
to Forms versus WPF. I overlooked that your question was specifically
about WPF (trying putting it all caps next time :) ). As far as I know,
in WPF the Panel class doesn't support scrolling. Instead, I think you
want the ScrollViewer class.

Pete

thanks, wasn't having much luck figuring how to use a panel as a listbox
type object
will look at scrollViewer
mark
 
M

mp

Hi
Given two listboxes side by side on a wpf form
Trying to think of a way to cause the scroll bar of either to move both
Similar to windiff or winmerge windows where two files can be viewed side
by
side and scrolling affects both panes.
thnaks for any ideas
mark

I used two ListViews and ScrollIntoView method.
It's not exactly pretty, but it was for a one-off
in-house tool.
 
P

Peter Duniho

thanks, wasn't having much luck figuring how to use a panel as a listbox
type object
will look at scrollViewer

Even with ScrollViewer, it's not that you should use it "as a ListBox type
object". It's that the ScrollViewer should be used as a container for the
ListBox. That is, the ListBox is a child control of the ScrollViewer.

Pete
 
M

mp

Peter Duniho said:
Even with ScrollViewer, it's not that you should use it "as a ListBox type
object". It's that the ScrollViewer should be used as a container for the
ListBox. That is, the ListBox is a child control of the ScrollViewer.

Pete

gotcha, I;ll just have to look into how that works
thanks
mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top