私は WPF アプリケーションを作成しており、最善のバインディング アプローチを見つけようとしていますが、「ハック」ソリューションしか考えていません。より良い方法があることを願っています。
Grid 内に Border オブジェクト (FrameworkElement から派生) があります。子 TextBlock のテキストが変更されると、Border のサイズが変更される場合があります。ボーダーが存在するセルがグリッド内の他のものによって再配置される可能性があるため、ボーダーの位置が変わる場合があります。
画面の左下隅から Border オブジェクトの正確な中心まで Line を描画したいと考えています。Border の正確な中心にある線の終点は、Border のサイズや画面上の位置に関係なく、常に中心にある必要があります。
どうすればこれを達成できますか?
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.