You could inherit the TabControl (or add an attached property) which controls if navigation to another tab item is allowed; however, let me just stress that 'no codebehind' is kinda silly - there are plenty of times when code-behind can be used for view-only purposes, and that's ok Back to the problem... what you'd do using my suggestion is hide the code-behind (checking if the action is allowed) inside a control, so that the actual view (the page/window etc) doesn't contain it. If you declare the new property as a DependencyProperty you get all the binding facilities etc.
You could inherit the TabControl (or add an attached property) which controls if navigation to another tab item is allowed; however, let me just stress that 'no codebehind' is kinda silly - there are plenty of times when code-behind can be used for view-only purposes, and that's ok. Back to the problem... what you'd do using my suggestion is hide the code-behind (checking if the action is allowed) inside a control, so that the actual view (the page/window etc) doesn't contain it. If you declare the new property as a DependencyProperty you get all the binding facilities etc.
Ya I am ready to use even the code behind , but all the data dn data context are being driven from the view model, this is in a way obstructing me to just seperate all the implementation from the viewmodel to codebehind. – crazy9 Aug 28 '10 at 22:41.
EDIT: I tested my other code and it didn't work. Was just an idea anyways. Here's a method that does work (although I agree with Alex that code behind in MVVM is fine when adjusting the View).
In this case I created a converter which takes two boolean values: If the tab is selected and if we can change tabs. If both of these are set to false, we return false to disable the tab. If either is set to true, we leave the tab enabled.
Here's the code. I have a property in my VM called CanChangeTabs and an instance of MyConverter in Window. Resources called Converter.
XAML inTabItem: Converter: public class MyConverter : IMultiValueConverter { public object Convert(object values, Type targetType, object parameter, CultureInfo culture) { foreach (object value in values) { if ((bool)value) { return true; } } return false; } public object ConvertBack(object values, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }.
Ya tried the code but, Throwing an error "The attached property Style. Triggers cannot be defined in setter or one of its base classes" – crazy9 Aug 27 '10 at 17:20 Yeah I didn't throw the code through an editor and forgot an end tag for the setter. I decided to try the code out and it didn't work anyways so I updated the post with a working solution.
– Rachel Aug 27 '10 at 18:43 The code do work but the only problem is , only after I get into the particilar tab, it is getting disabled, I gues this is bcoz the coverter is getting implemeted on Is enabled only after the selcetion on that particular tab item. – crazy9 Aug 28 '10 at 21:33.
In this case I created a converter which takes two boolean values: If the tab is selected and if we can change tabs. If both of these are set to false, we return false to disable the tab. If either is set to true, we leave the tab enabled.
Here's the code. I have a property in my VM called CanChangeTabs and an instance of MyConverter in Window. Resources called Converter.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.