Without knowing what those Commands do it is not possible for me to reproduce your full scenario and your issue. I’ll try to interpret the situation based on your previous questions, but let me know if I’m
not on target.
What you are trying to do is pass the
ContentControl to some method (probably in your ViewModel), and trying to create a Region with it. I assume you are using the selection changed event because when a new row is added to a
DataGrid that event is published. If this is your scenario, you will be in the same situation Guido mentioned, having more than one region with the same name under the same region manager (assuming _regionManager instance is the same).
Additionally, if you are not getting an error because there are multiple controls named “contentControler”, it could be because they are not being added to the same XAML Namescope, as
templates define their own namescope. Therefore, as the ElementName binding requires elements to be in either the current “XAML namescope or the XAML namescope of the templated parent if the binding target is in a data template
or control template” (as explained
here), the binding would not work properly.
The question that needs to be asked is why each row should define a new region (always considering that each of the Regions would have a different name). What is the scenario that it would help you achieve? How
would the views be added? I ask this, because there might be different ways around this.
creating a RegionAdapter for the DataGrid could be a viable approach. Then you could define the
DataGrid as a region, and the different added views could be shown in each row (similar to how an
ItemsControl region works).
Please let me know if this helps.