refactor: chapter control progress bar bindings#717
Conversation
There was a problem hiding this comment.
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.
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.
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.
Yeah, it still seems useful in certain situations (like in this one).
huynhsontung
left a comment
There was a problem hiding this comment.
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.