简体   繁体   中英

How do you bind in xaml to a dynamic xpath?

I have a list box that displays items based on an XPath query.

This XPath query changes depending on the user's selection elsewhere in the GUI. The XPath always refers to the same document.

At the moment, I use some C# code behind to change the binding of the control to a new XPath expression.

I'd like instead to bind in XAML to an XPath, then change the value of that XPath as required.

How would I do that?

I think that you're trying to over complicate the problem. But have you thought about allocating the XPath to a dynamic resource:

<....   ={Binding XPath={DynamicResource:res resource-name}} ... />

The best place to read about all-binding is Beatriz's blog: http://www.beacosta.com/blog/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM