0

I have the following layout for a screen displaying multi-channel information (similar to audio tracks):

  1. MultiChannelPlotterControl contains one HorizontalRuler instance at the bottom and a UniformGrid containing N SingleChannelPlotterControl instances;
  2. Each SingleChannelPlotterControl has one instance of VerticalRuler aligned to left;

enter image description here

Problems are:

  1. Each vertical ruler can have a different Width, but I would like them all to stretch to the largest width so that they could fit, but since they are on different controls, I cannot put them in the same container (another UniformGrid, for example. Now if I decide to put them together in a different container, they would not be part of the SingleChannelPlotterControl anymore;
  2. There is a rectangular region on the bottom left corner. That is supposed to have the same Width of the VerticalRuler(s), but it is still higher in the layout tree. It is currently empty, but I could put something there and bind its Width, for example;

So the question is:

How could I Layout/Element-Bind/Style these controls so that right edge of the Vertical Rulers keep aligned to each other (fitting the widest one) and with the left edge of the Horizontal Ruler?

EDIT: I guess I could create a "LeftPanelWidth" DependencyProperty on MultiChannelPlotterControl, and on its getter use some VisualTreeHelper wizardry to get ActualWidths for every VerticalRuler inside, but how would I choose the largest width and set the widths of the others?

4

2 回答 2

0

您可以尝试在列定义上使用 SharedSizeGroup 属性。您必须在正确的父容器上设置 IsSharedSizeScope=True。

于 2016-01-19T12:28:09.207 回答
0

我最终通过消除SingleChannelPlotterControl类来解决问题。

相反,我使用两个并排的UniformGrid实例(作为ItemsPanel两个ItemsControl实例的),将它们设置为在 XAML 中声明ItemsSource的相同。CollectionViewSource

然后,对于每个ItemsControl我声明一个不同ItemTemplate的 ,左边的一个包含 a VerticalRuler,另一个以与SingleChannelPlotterControl以前相同的方式显示信号 - 除了它不再包含标尺。

于 2016-01-19T16:58:09.760 回答