I have a WPF project (c#, MVVM using MVVM Light) and I have a MultiBinding that passes information to a converter, as you would expect.
The code for that is here:
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Path Stroke = "{Binding LineColour}" >
< Path.Data >
< MultiBinding Converter="{StaticResource NodeToPathDataConverter}">
<Binding Path = "NodeListViewModel.NodeList" Source="{StaticResource Locator}" />
<Binding />
</MultiBinding>
</Path.Data>
</Path>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
The converter then uses the information from these bindings to spit out the details for the line. The problem is that the line goes from the (0,0) position of one control to another, but I want it to go from the middle of the controls in question. To do this, the converter in the MultiBinding needs to get the ActualWidth and ActualHeight of the controls in question.
So what are the controls in question? I have another almost identical ListBox control below this one that uses the same data set, but instead of drawing lines between controls, it draws the controls themselves. This is as follows:
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Thumb Name = "myThumb" Template="{StaticResource NodeVisualTemplate}">
<i:Interaction.Triggers>
<i:EventTrigger EventName = "DragDelta" >
< cmd:EventToCommand Command = "{Binding NodeListViewModel.DragDeltaCommand, Source={StaticResource Locator}}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Thumb>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
The reason I used two ListBox controls was to ensure that all lines appeared lower than all Thumbs. I tried many ways of them in the same ListBox, but it wasn't going to happen. They do share the same data set though, which is a 'NodeList'.
So the bit I can't figure out is how to get the ActualWidth and ActualHeight of the Thumbs in the second ListBox into the converter in the first ListBox. Which is why I'm here.
Any help would be greatly appreciated.