Question : How to change the regualr property to the automated property for which the automated property is working fine

I have a property where we are returning the filter command and its working fine and actually I need to close the menu popup after it shows the data based on that filter.When I am using the automated property instead of (Public Icommans ApplyFilterCommand{get ; privateset; )returning anything it works fine as I have used it in many places for closing the menu popup and It closes fine .Below is the code.Could any one please help me out with this issue.

//This is working fine for filtering but as we are not setting any value
 public ICommand ApplyFilterCommand
        {
            get
            {
               
                return this.Commands[SR.ApplyFilter];
            }
                         }
//This is the one declared in the constructor and closemenucommand is the function which we are using to close the menu and we are declaring this in the constructor.
this.ApplyFilterCommand = new DelegateCommand<string>(this.CloseMenuCommand);

 public void CloseMenuCommand(string parameter)
        {
            Microsoft.Advertising.Controls.MenuService.CloseMenu();
        }

//But if we use automated property the filtering is not working but menu is closeing fine.I am not able to figure out how to include the filter command in get and do the same thing in set as in automated property.

public ICommand ApplyFilterCommand
        {
           get;
     private set;

        }
this.ApplyFilterCommand = new DelegateCommand<string>(this.CloseMenuCommand);

 public void CloseMenuCommand(string parameter)
        {
            Microsoft.Advertising.Controls.MenuService.CloseMenu();
        }

My goal is to return the filter in get and do the same thing as it does in automated property for set.Could any one please help me out with this issue.Thanks in advance.

Answer : How to change the regualr property to the automated property for which the automated property is working fine

You need to extend this class and then override the constructor of base class to apply the new setting which you are trying to set.

Secondly, you need to change this method to use the parameter which is sent from the calling method to properly identify which menu need to be closing assuming parameter is sending the name of the menu

 public void CloseMenuCommand(string parameter)
        {
            Microsoft.Advertising.Controls.MenuService.CloseMenu();
        }


Random Solutions  
 
programming4us programming4us