XAML Path Is Not Recognized

RogerSchlueter-7899 1,756 Reputation points
2026-08-07T10:42:45.7433333+00:00

I am working with a Transactions class:

Public Class Transactions
	....
	Public Property CurrentTransaction As Transaction
	Public Property Details as DataTable
	
End Class

The Details table has a "CategoryID" column. In the wpf for a Transaction I have:

<Window
	....
	<ComboBox
		x:Name="cbxCategories"
		DataContext="CurrentTransaction/Details.DefaultView"
		DisplayMemberPath="Name"
		HorizontalAlignment="Stretch"
		Margin="0,0,5,4"
		SelectedValue="{Binding Path=CategoryID}"
		SelectedValuePath="CategoryID" />
	....
</Window>

This gives a run-time error:

BindingExpression path error: 'CategoryID' property not found on 'object' ....

What is wrong with my binding?

Developer technologies | Windows Presentation Foundation
0 comments No comments

2 answers

Sort by: Most helpful
  1. Tony Thach (WICLOUD CORPORATION) 240 Reputation points Microsoft External Staff Moderator
    2026-08-07T12:29:47.82+00:00

    We are currently investigating the issue and will provide an update soon. Thank you for your patience.

    Was this answer helpful?

    1 person found this answer helpful.

  2. AI answer

    2026-08-07T10:43:00.9766667+00:00

    Path=CategoryID is being resolved against the current binding source, and that source is not the row/view object that exposes CategoryID.

    The main issue is this line:

    DataContext="CurrentTransaction/Details.DefaultView"
    

    That sets a literal string, not a binding expression. In WPF, property paths for data binding must be used through a binding, for example Path="propertyName/propertyNameX" when traversing a hierarchy.

    Use a real binding for the source, for example:

    <ComboBox
        x:Name="cbxCategories"
        DataContext="{Binding CurrentTransaction/Details.DefaultView}"
        DisplayMemberPath="Name"
        HorizontalAlignment="Stretch"
        Margin="0,0,5,4"
        SelectedValue="{Binding CategoryID}"
        SelectedValuePath="CategoryID" />
    

    Key points:

    1. CurrentTransaction/Details.DefaultView must be inside {Binding ...}.
    2. In WPF binding paths, / is used for source traversal in hierarchical data.
    3. SelectedValue="{Binding CategoryID}" only works if the DataContext is an item that actually has a CategoryID property/column.

    If the error continues, inspect the actual runtime binding source in Visual Studio:

    • Start debugging.
    • Open Debug > Windows > XAML Binding Failures.
    • Check the Data Context, Binding Path, and Description columns to see what object WPF is using for CategoryID.

    That will show whether the ComboBox is bound to the expected row/view object or to some other object that does not contain CategoryID.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.