-
-
Notifications
You must be signed in to change notification settings - Fork 119
refactor: chapter control progress bar bindings #717
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modernizes the XAML data binding in the ChapterProgressBar control by migrating from runtime Binding to compile-time x:Bind syntax, which provides better performance and compile-time type checking.
- Converted all four property bindings (Width, Maximum, Minimum, Value) from
Bindingtox:Bindwith explicitMode=OneWay
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -18,11 +18,11 @@ | |||
|
|
|||
| <DataTemplate x:Key="ItemTemplate" x:DataType="viewModels:ChapterViewModel"> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of spamming Mode=OneWay I could have just done:
<DataTemplate
x:Key="ItemTemplate"
x:DataType="viewModels:ChapterViewModel"
x:DefaultBindMode="OneWay">There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh I don't know about that. I think explicitly state binding mode still has its merits. I rely on the fact that x:Bind defaults to OneTime quite often. I don't know if implicitly changing the binding mode is a good idea here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it still seems useful in certain situations (like in this one).
huynhsontung
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly, I used Bindings here for a reason. When I last tested this, there were some edge cases where ItemRepeater and x:Bind don't play nice together. Did you encounter any issues in your testing?
No, but I haven't tested it extensively. Just a couple of files with chapters. But now that I know you've run into issues, I'll test it with a few more. |
Can confirm. Works correctly for the first file in a session, but subsequent files incorrectly applies the The <ItemsControl ItemTemplate="{StaticResource ItemTemplate}" ItemsSource="{x:Bind ProgressItems}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" Spacing="1" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl> |
No description provided.