I am trying to do things the .net way and declare my menu items for my context menu like a good citizen in xaml :).
I have a listbox that contains a bunch of list items based of ItemsSource.
QUESTION: How can I dynamically set the visibility of a particular menu item based off a function to be defined in the Page class?
I could just data bind this to a property in my DataContext class, but there are a few things that are more ui-specific that it really should not know about, so I'd like to keep it clean.
Can I somehow bind the visibility to a function in the page class and pass it the data context and have it return the appropriate visibility value required? Or is there another way?
Thanks! swine
Bindings are useful because the UI updates whenever the bound value changes. Since a function doesn't update, even if you could bind to a function, the UI would never change. The UI would also never know when to call the bound function.
Why don't you just bind to a bool DataProperty
and then use the function to update the bool. If you explain more of what you are trying to do, then I can give you a more detailed solution.