Skip to content

Fix ItemContainer SelectedBrush with custom BorderBrush#279

Open
marko1olo wants to merge 1 commit into
miroiu:masterfrom
marko1olo:fix-itemcontainer-selected-brush
Open

Fix ItemContainer SelectedBrush with custom BorderBrush#279
marko1olo wants to merge 1 commit into
miroiu:masterfrom
marko1olo:fix-itemcontainer-selected-brush

Conversation

@marko1olo

@marko1olo marko1olo commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #70

Description of the Change

This updates the default ItemContainer template so selection, preview-selection, and pending-connection highlight brush changes are applied to the named border inside the control template instead of setting ItemContainer.BorderBrush from inherited style triggers.

That keeps a custom BorderBrush setter in a BasedOn ItemContainer style from overriding the selected visual state, while still allowing an explicitly configured SelectedBrush to control the selected border color.

Verification performed:

  • dotnet build Nodify\Nodify.csproj -f net8-windows
  • dotnet build Nodify\Nodify.csproj -f net9-windows --no-restore
  • dotnet build Nodify\Nodify.csproj -f net10.0-windows --no-restore
  • Temporary WPF smoke check: derived ItemContainer style with BorderBrush=Blue and SelectedBrush=Red rendered the inner border blue when unselected and red when selected.
  • git diff --check

Possible Drawbacks

The selected, preview-selected, and highlight states now change the template border's BorderBrush rather than the effective ItemContainer.BorderBrush dependency property value. This preserves the visual behavior and avoids BasedOn style precedence issues, but code that read ItemContainer.BorderBrush while selected would now continue to see the configured base brush.

  • dotnet build Examples\Nodify.Calculator\Nodify.Calculator.csproj -f net8-windows
  • dotnet build Examples\Nodify.Playground\Nodify.Playground.csproj -f net8-windows
  • dotnet build Examples\Nodify.Shapes\Nodify.Shapes.csproj -f net8-windows
  • dotnet build Examples\Nodify.StateMachine\Nodify.StateMachine.csproj -f net8-windows

@miroiu

miroiu commented Jun 6, 2026

Copy link
Copy Markdown
Owner

This fix is a breaking change because it will require everyone who overrides the ItemContainer.Template to manually manage the border brush. This affects the Shapes and Workflow example applications.

@marko1olo
marko1olo force-pushed the fix-itemcontainer-selected-brush branch from a8c67ba to 6f8a0b0 Compare June 7, 2026 15:08
@marko1olo

Copy link
Copy Markdown
Contributor Author

Thanks for calling that out. I updated the branch so the default template still has the inner Border template triggers, but the style-level BorderBrush setters are restored as well.

That keeps derived ItemContainerStyle setters from overriding the default template's selected/highlight visuals, while custom ItemContainer.Template implementations such as the Shapes example can still bind to ItemContainer.BorderBrush and get the selected/preview/pending-connection state.

Local checks:

  • dotnet build Nodify\Nodify.csproj -f net10.0-windows
  • dotnet build Examples\Nodify.Shapes\Nodify.Shapes.csproj -f net8-windows
  • dotnet build Examples\Nodify.Workflow\Nodify.Workflow.csproj -f net10.0-windows (passes with the existing _layer unused-field warning)
  • git diff --check

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.

[Bug] Changing BorderThickness will cause an exception to be displayed when nodes are selected

2 participants