Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: [Prism 5] RegionName in ItemsControl DataTemplate

$
0
0
Thanks GOstrowsky You saved my life :) :)

I've just downloaded your code, and it works perfectly, however, it adds a view one time, for the second it raises the following exception:

Exception

I solved the problem by adding a new static variable to avoid get the same views names in the the region manager as the following:
privatestaticint viewCounter;

        public HelloWorldViewModel()
        {
            AddView = new DelegateCommand
                (
                () =>
                    {
                        viewCounter++;
                        ServiceLocator.Current.GetInstance<IRegionManager>().Regions["RegionInsideDataTemplate"].Add(
                            string.Format("View {0} added through View Injection", viewCounter));
                    }
                );

            MyRegionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
            RaisePropertyChanged("MyRegionManager");
        }
Thanks a lot :)

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>