HandyOrg / HandyOrg/HandyControl

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Primitives.MenuBase', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'MenuItem' (Name=''); target property is 'Padding' (type 'Thickness')

Open
#1,474 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
7.2k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Primitives.MenuBase', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'MenuItem' (Name=''); target property is 'Padding' (type 'Thickness')

Steps to reproduce the bug
                    <hc:SplitButton
                        x:Name="BtnResetChip" Height="auto"
                        Command="{Binding BtnResetChipCommand}"
                        CommandParameter="hard" Content="复位">
                        <hc:SplitButton.DropDownContent>
                            <StackPanel Width="88">
                                <MenuItem Command="{Binding BtnResetChipCommand}" CommandParameter="soft" Header="软复位"/>
                            </StackPanel>
                        </hc:SplitButton.DropDownContent>
                    </hc:SplitButton>

Expected behavior

No response

Screenshots

No response

NuGet package version

HandyControl 3.4.0

IDE

Visual Studio 2022

Framework type

.Net 6.0

Windows version

Windows 11 (22000)

Additional context

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided XAML with HandyControl's SplitButton, its DropDownContent, and the nested MenuItem on .NET 6/WPF. Inspect the SplitButton and MenuItem binding behavior, then define the expected behavior before changing anything; completion should eliminate the reported binding error without breaking the dropdown command.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.