Fix Player and RoomCountBox tooltip not updating#242
Fix Player and RoomCountBox tooltip not updating#242Packsolite wants to merge 1 commit intoTeamWheelWizard:devfrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe changes migrate tooltip implementation from custom Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can generate a title for your PR based on the changes.Add |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@WheelWizard/Views/Layout.axaml`:
- Around line 69-76: The StateBox instances (PlayerCountBox and RoomCountBox)
are setting the attached ToolTip.Tip instead of the control's TipText property
which the template binds to via TemplateBinding; change the properties on these
StateBox controls to set TipText (e.g., TipText="{x:Static
lang:Phrases.Hover_PlayersOnline_0}" and TipText="{x:Static
lang:Phrases.Hover_RoomsOnline_0}") so the template's Border tooltip receives
the value.
In `@WheelWizard/Views/Layout.axaml.cs`:
- Around line 199-218: The code currently uses ToolTip.SetTip(...) on
PlayerCountBox and RoomCountBox which sets the attached ToolTip property on the
control but is ignored by the StateBox template that reads TipText via
TemplateBinding; replace the ToolTip.SetTip calls by assigning the computed
strings to the TipText property on the StateBox instances (e.g.
PlayerCountBox.TipText = ... and RoomCountBox.TipText = ... using the same
playerCount/roomCount switch logic) and remove the ToolTip.Tip bindings from the
StateBox elements in the layout so the template-bound Border reads the new
TipText values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: f367e0d7-4f37-4d12-bdb6-73c1fcfc79c5
📒 Files selected for processing (2)
WheelWizard/Views/Layout.axamlWheelWizard/Views/Layout.axaml.cs
| <components:StateBox x:Name="PlayerCountBox" Text="0" Variant="Dark" | ||
| IconData="{StaticResource UserCouple}" | ||
| TipText="{x:Static lang:Phrases.Hover_PlayersOnline_0}" | ||
| ToolTip.Tip="{x:Static lang:Phrases.Hover_PlayersOnline_0}" | ||
| Margin="10,0,0,0" /> | ||
| <components:StateBox x:Name="RoomCountBox" Text="0" Variant="Dark" | ||
| IconData="{StaticResource RoomUsers}" | ||
| TipText="{x:Static lang:Phrases.Hover_RoomsOnline_0}" | ||
| ToolTip.Tip="{x:Static lang:Phrases.Hover_RoomsOnline_0}" | ||
| Margin="10,0,0,0" /> |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify how StateBox template handles tooltips
echo "=== StateBox.axaml tooltip binding ==="
rg -n "ToolTip.Tip" --type=xml -C3 -g "*StateBox*"
echo ""
echo "=== TipText property definition ==="
ast-grep --pattern $'public static readonly StyledProperty<string> TipTextProperty = $_'Repository: TeamWheelWizard/WheelWizard
Length of output: 853
🏁 Script executed:
fd -type f "StateBox.axaml.cs"Repository: TeamWheelWizard/WheelWizard
Length of output: 241
🏁 Script executed:
# Search for TipText property in StateBox files
rg -n "TipText" -C5 -g "*StateBox*"Repository: TeamWheelWizard/WheelWizard
Length of output: 5855
Set TipText property instead of ToolTip.Tip attached property on StateBox controls.
The StateBox template (in StateBox.axaml:30) binds its internal Border's tooltip via ToolTip.Tip="{TemplateBinding TipText}". Setting ToolTip.Tip directly on the StateBox control here will not work because the TemplateBinding explicitly binds to the TipText property, which remains unset.
Use the TipText property instead (as seen in other StateBox usages in the codebase):
Example fix
- <components:StateBox x:Name="PlayerCountBox" Text="0" Variant="Dark"
+ <components:StateBox x:Name="PlayerCountBox" Text="0" Variant="Dark" TipText="..."
IconData="{StaticResource UserCouple}"
- ToolTip.Tip="{x:Static lang:Phrases.Hover_PlayersOnline_0}"
Margin="10,0,0,0" />🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@WheelWizard/Views/Layout.axaml` around lines 69 - 76, The StateBox instances
(PlayerCountBox and RoomCountBox) are setting the attached ToolTip.Tip instead
of the control's TipText property which the template binds to via
TemplateBinding; change the properties on these StateBox controls to set TipText
(e.g., TipText="{x:Static lang:Phrases.Hover_PlayersOnline_0}" and
TipText="{x:Static lang:Phrases.Hover_RoomsOnline_0}") so the template's Border
tooltip receives the value.
| ToolTip.SetTip( | ||
| PlayerCountBox, | ||
| playerCount switch | ||
| { | ||
| 1 => Phrases.Hover_PlayersOnline_1, | ||
| 0 => Phrases.Hover_PlayersOnline_0, | ||
| _ => Humanizer.ReplaceDynamic(Phrases.Hover_PlayersOnline_x, playerCount) | ||
| ?? $"There are currently {playerCount} players online", | ||
| } | ||
| ); | ||
| RoomCountBox.Text = roomCount.ToString(); | ||
| RoomCountBox.TipText = roomCount switch | ||
| { | ||
| 1 => Phrases.Hover_RoomsOnline_1, | ||
| 0 => Phrases.Hover_RoomsOnline_0, | ||
| _ => Humanizer.ReplaceDynamic(Phrases.Hover_RoomsOnline_x, roomCount) ?? $"There are currently {roomCount} rooms active", | ||
| }; | ||
| ToolTip.SetTip( | ||
| RoomCountBox, | ||
| roomCount switch | ||
| { | ||
| 1 => Phrases.Hover_RoomsOnline_1, | ||
| 0 => Phrases.Hover_RoomsOnline_0, | ||
| _ => Humanizer.ReplaceDynamic(Phrases.Hover_RoomsOnline_x, roomCount) ?? $"There are currently {roomCount} rooms active", | ||
| } | ||
| ); |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Avalonia ToolTip attached property inheritance vs TemplateBinding precedence
💡 Result:
In Avalonia, these are two separate mechanisms:
1) Inheritance (“inherits: true”) is low precedence
Property inheritance only applies to properties registered with inherits: true, and inherited values use BindingPriority.Inherited, which is lower priority than styles and templates. (docs.avaloniaui.net)
So even if an attached property is inheritable, an inherited value will lose to any template-provided value.
2) TemplateBinding is BindingPriority.Template (higher than styles + inheritance)
Values coming from a ControlTemplate (including TemplateBinding) use BindingPriority.Template, which is higher priority than Style and Inherited. (docs.avaloniaui.net)
Implication: if a template part sets ToolTip.Tip="{TemplateBinding ToolTip.Tip}", then:
- A style setter on that template part generally won’t override it (style is lower priority than template). (docs.avaloniaui.net)
- A local value on that template part will override it (local is higher than template). (docs.avaloniaui.net)
3) ToolTip.Tip specifically: don’t assume it inherits
ToolTip.Tip is an attached property defined by ToolTip. (docs.avaloniaui.net)
But not all tooltip attached properties are inheritable (e.g., ShowOnDisabled is explicitly registered as inheritable in Avalonia). (stackoverflow.com)
So if you’re expecting ToolTip.Tip to “flow down” the tree via inheritance, it may not—whereas TemplateBinding will still copy the templated parent’s value into the template part.
Practical rule of thumb
- If you want the tooltip content to be customizable from the control instance, bind it in the template (
TemplateBinding). - If you want to override the tooltip on a specific element inside the template, set
ToolTip.Tiplocally on that element (or modify the template), because plain style setters typically won’t beat a template-set value. (docs.avaloniaui.net)
Citations:
- 1: https://docs.avaloniaui.net/docs/guides/styles-and-resources/setter-precedence?utm_source=openai
- 2: https://docs.avaloniaui.net/docs/guides/styles-and-resources/setter-precedence?utm_source=openai
- 3: https://docs.avaloniaui.net/docs/guides/styles-and-resources/setter-precedence?utm_source=openai
- 4: https://docs.avaloniaui.net/docs/guides/styles-and-resources/troubleshooting
- 5: https://docs.avaloniaui.net/docs/reference/controls/tooltip?utm_source=openai
- 6: https://stackoverflow.com/questions/79819580/how-to-globally-override-the-default-value-of-a-property-in-avalonia?utm_source=openai
- 7: https://docs.avaloniaui.net/docs/guides/styles-and-resources/troubleshooting
🏁 Script executed:
find . -type f -name "StateBox.axaml*" | head -5Repository: TeamWheelWizard/WheelWizard
Length of output: 165
🏁 Script executed:
find . -type f -name "Layout.axaml*" | head -5Repository: TeamWheelWizard/WheelWizard
Length of output: 139
🏁 Script executed:
cat -n ./WheelWizard/Views/Components/StateBox.axamlRepository: TeamWheelWizard/WheelWizard
Length of output: 9504
🏁 Script executed:
cat -n ./WheelWizard/Views/Components/StateBox.axaml.csRepository: TeamWheelWizard/WheelWizard
Length of output: 3895
🏁 Script executed:
sed -n '199,218p' ./WheelWizard/Views/Layout.axaml.csRepository: TeamWheelWizard/WheelWizard
Length of output: 868
🏁 Script executed:
sed -n '71,75p' ./WheelWizard/Views/Layout.axamlRepository: TeamWheelWizard/WheelWizard
Length of output: 458
🏁 Script executed:
sed -n '65,80p' ./WheelWizard/Views/Layout.axamlRepository: TeamWheelWizard/WheelWizard
Length of output: 1009
Use the TipText property instead of ToolTip.SetTip(); direct attached property setting bypasses the template binding.
The StateBox template binds its internal Border's ToolTip.Tip to the TipText property via TemplateBinding (StateBox.axaml:30). Calling ToolTip.SetTip() on the StateBox instance sets the attached property on the control itself, but the Border (which renders the tooltip) only reads from TipText. Setting StateBox.ToolTip.Tip has no effect on what displays.
Assign to TipText directly instead:
🔧 Proposed fix
PlayerCountBox.Text = playerCount.ToString();
- ToolTip.SetTip(
- PlayerCountBox,
- playerCount switch
- {
- 1 => Phrases.Hover_PlayersOnline_1,
- 0 => Phrases.Hover_PlayersOnline_0,
- _ => Humanizer.ReplaceDynamic(Phrases.Hover_PlayersOnline_x, playerCount)
- ?? $"There are currently {playerCount} players online",
- }
- );
+ PlayerCountBox.TipText = playerCount switch
+ {
+ 1 => Phrases.Hover_PlayersOnline_1,
+ 0 => Phrases.Hover_PlayersOnline_0,
+ _ => Humanizer.ReplaceDynamic(Phrases.Hover_PlayersOnline_x, playerCount)
+ ?? $"There are currently {playerCount} players online",
+ };
RoomCountBox.Text = roomCount.ToString();
- ToolTip.SetTip(
- RoomCountBox,
- roomCount switch
- {
- 1 => Phrases.Hover_RoomsOnline_1,
- 0 => Phrases.Hover_RoomsOnline_0,
- _ => Humanizer.ReplaceDynamic(Phrases.Hover_RoomsOnline_x, roomCount) ?? $"There are currently {roomCount} rooms active",
- }
- );
+ RoomCountBox.TipText = roomCount switch
+ {
+ 1 => Phrases.Hover_RoomsOnline_1,
+ 0 => Phrases.Hover_RoomsOnline_0,
+ _ => Humanizer.ReplaceDynamic(Phrases.Hover_RoomsOnline_x, roomCount)
+ ?? $"There are currently {roomCount} rooms active",
+ };Also remove the ToolTip.Tip bindings in Layout.axaml (lines 71, 75) on both StateBox elements and rely solely on TipText assignments.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@WheelWizard/Views/Layout.axaml.cs` around lines 199 - 218, The code currently
uses ToolTip.SetTip(...) on PlayerCountBox and RoomCountBox which sets the
attached ToolTip property on the control but is ignored by the StateBox template
that reads TipText via TemplateBinding; replace the ToolTip.SetTip calls by
assigning the computed strings to the TipText property on the StateBox instances
(e.g. PlayerCountBox.TipText = ... and RoomCountBox.TipText = ... using the same
playerCount/roomCount switch logic) and remove the ToolTip.Tip bindings from the
StateBox elements in the layout so the template-bound Border reads the new
TipText values.
|
Hey, before you spend any more time on this |
681fd28 to
07e76a7
Compare

Purpose of this PR:
This PR fixes my previously reported issue #241 for the tooltips for the player and room count boxes not updating correctly.
How to Test:
What Has Been Changed:
TipTextwithToolTip.TipinLayout.axaml.ToolTip.SetTipinLayout.axaml.cs.Related Issue Link:
#241
Checklist before merging
No because i have not found any matching examples.
Summary by CodeRabbit
Refactor
Chores