Hey guys,

I am setting my viewmodel as datacontext in my xaml but I override it to my view to make few functions work however to achieve the visibility on some grids and I have a property in my VM can I override my datacontext back to my VM? If so how? I have a stackpanel that has datacontext overriden as my grid and within that stackpanel I need to change the datacontext for a button.

Any help will be appreciated thanks

The problem is that you have switched data contexts so your xaml code doesn't know anything about your property in the viewmodel. You will have to do a RelativeSource binding, something like this:

{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type YourView}}, Path=yourProperty}
commented: fixed my problem thanks +3