Two issues in dynamicRoutes parameter and data binding in the partial view class

Feb 25, 2014 at 9:16 PM
While I was trying to find a solution to a previous problem I asked about in this forum regarding loading a secondary view dynamically in a view with Primary-Secondary layout, I came across two issues that I think should be fixed or improved.
  • In the Controller class and inside the Execute method, there is a check for the type of parameters on the controller instance method in order to know which method to invoke:
if (routedParameters.ContainsKey(expectedParameterName) &&
                                    expectedParameter.ParameterType == routedParameters[expectedParameterName])
                                    paras.Add(requestContext.RouteData.Data[expectedParameterName]);
especially the line expectedParameter.ParameterType == routedParameters[expectedParameterName], shouldn't this use instance of or IsAssignableFrom() instead of strict comparison as this prevents someone from sending a subclass of an abstract base class or an implementation of an interface ?
  • Looking at the source code of PartialView.cs I found out that the View property is registered as dependency property with a different name, that is Document:
DependencyProperty ViewProperty = DependencyProperty.Register("Document" ...
This prevents someone from binding to the view property using the binding markup, because there is no dependency property defined on partial view with name View, Why ?

This caused me a couple of problems, so I am considering modifying the source code and I have two questions:
  1. Is modifying the name of the registered property to View instead of Document and checking for subtype might cause problems in other areas of the application ?
  2. Is this intentional by the framework authors, What's the point ?
Thank you so much for taking the time to read all of the questions and taking the time to answer thoroughly, I appreciate that.

Regards
Coordinator
Feb 26, 2014 at 1:08 AM
You are right. This looks fishy. I will take a look. Thanks for reporting this.


Markus
Jun 1, 2015 at 3:13 AM
Markus, what did you discover in regard to this?
Coordinator
Jun 3, 2015 at 3:52 AM
I think this was fixed a long time ago, if I am not mistaken.


Markus