I'm writing a WPF application and I'm trying to figure out the best binding approach but have been coming up only "hack" solutions and I'm hoping there's a better way.
I have a Border object (which derives from FrameworkElement) inside a Grid. The Border's size may change because of a child TextBlock's text changing. The Border's position may change because other things in the Grid may rearrange the cell that the Border lives in.
I want to draw a Line from the lower left corner of the screen to the exact center of the Border object. The endpoint of the line that's in the exact center of the Border must always remain in the center regardless of what the Border's size or position on the screen.
How can I accomplish this?
My idea is that binding to a dependency property seems to be the ideal way to handle this. I could use an IValueConverter on a Binding object to calculate the exact center given it's ActualWidth, ActualHeight, and TranslatePoint() to find the upper left corner. However, I can't figure out what dependency property I should bind to that will alert me when the Border changes size and/or position.