Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ContentAlignment bindings from TreeViewItem #766

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

koal44
Copy link
Contributor

@koal44 koal44 commented Sep 21, 2023

Remove Vertical/HorizontalContentAlignment properties from TreeViewItem as it tightly couples TreeView to TreeViewItem through an ancestor binding which can lead to binding failures under certain conditions.

Pull request type

  • Bugfix

What is the current behavior?

ContentAlignment style setters such in TreeViewItem.xaml such as: <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type TreeView}}}" />

Issue Number: N/A

What is the new behavior?

The alignment setters have been removed. To re-style the TreeViewItem controls I advise styling the control itself rather than doing so on TreeView.

Binding to ancestor ControlItem (TreeView), could, under certain conditions, incur binding errors during template switching as visual elements are torn down with TreeView destroyed before item bindings have been released.

This fix opts for a more standard and safer styling approach for TreeViewItem that doesn't require binding to an ancestor.
@pomianowski pomianowski merged commit ede2da1 into lepoco:development Oct 9, 2023
2 of 3 checks passed
@koal44 koal44 deleted the fix/treeview-alignment branch February 28, 2024 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants