Hi all,
I need to abstract some behavioural code and have a problem trying to reference the objects in the class that is calling these behaviours, let me try to explain:
My "parent" class, has a property called CurrentPage. I also have some behavioural logic, that modifies the CurrentPage property, currently this is written in the same class. I now need to reuse that behaviour in lots of places so I want to encapsulate/abstract that into a seperate ... erm... class??
I can sense that there is probably a design pattern that will meet my needs, but I can't figure out which one to use.
Can anyone out there help??
Thanks, Mark
(I am using C#, Silverlight and MVVM. CurrentPage is a notification property, not a field, so cannot be passed as a ref type into a Behaviour sub-class)
UPDATE: Example added as requested:
class MainApp
{
public static string CurrentPage { get; set; }
/// <summary>
/// Entry point into console application.
/// </summary>
static void Main()
{
CurrentPage = "Default value";
Console.WriteLine(CurrentPage);
DoWork();
Console.WriteLine(CurrentPage);
Console.ReadLine();
}
private static void DoWork()
{
CurrentPage = "A new page";
}
}
I'm trying to extract DoWork() into a seperate class.