I need to bind a property in my viewmodel to a property in a contentpane (IsEnabled for example). The following doesnt work, as I get an error that SetIsEnabledInTheVM is not a dependency property:
<igDock:TabGroupPane>
<igDock:ContentPane x:Name="contentPane">
<ContentControl>
<vm:MyViewModel SetIsEnabledInTheVM="{Binding ElementName=contentPane, Path=IsEnabled}" />
</ContentControl>
</igDock:ContentPane>
</igDock:TabGroupPane>
After some reading up, I think this should work if the VM is set as the datacontext of the ContentPane (or ContentControl?). But even if I do set the datacontext to my vm, I still dont see my view properly. Where should I be setting the datacontext here, and how do I then access the SetIsEnabledInTheVM property?
Thanks!
Actually IsActive is not related to being in view. IsActive is simply an indication that the ContentPane contains the keyboard focus. There is nothing in the XamDockManager classes that indicate if something is in view since really that is dependant upon the templates. Perhaps you could watch the IsVisible of the ContentControl that you have displaying your VM. Since this is a read-only property, you'd probably have to write your own attached behavior that would set a property on your vm when that changes.
Actually I think my example property was bad. Im trying to get each tabs viewmodel to know whether it is the visible tab or not. I think the property in ContentPane that reflects this state is IsActivePane. But, this is a readonly property, so it seems I cannot bind to it in the way you describe- I get an error that says 'is read-only and cannot be set from the markup'.
I dont want to set IsActivePane, just make use of its value in my viewmodel.
Any way I can do this?
nicros said: I need to bind a property in my viewmodel to a property in a contentpane (IsEnabled for example). The following doesnt work, as I get an error that SetIsEnabledInTheVM is not a dependency property:
Or if you really want the VM to be hosted within a ContentControl that is within the ContentPane: