Prism 和 AnimatedTabControl

发布于 2024-07-30 20:36:49 字数 1114 浏览 1 评论 0原文

我很想使用它,但我无法弄清楚如何将项目绑定到它。

我想看一个简单的例子,比如

Shell.xaml

<Controls:AnimatedTabControl
   x:Name="TestTab"
   SelectedIndex="0"
   VerticalAlignment="Stretch"
   cal:RegionManager.RegionName="{x:Static inf:RegionNames.TestRegion}" 
   Grid.Row="1"  
/>

--

using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Regions;

namespace HelloWorldModule
{
    public class HelloWorldModule : IModule
    {
        private readonly IRegionManager regionManager;
        public HelloWorldModule(IRegionManager regionManager)
        {
            this.regionManager = regionManager;
        }

       public void Initialize()
       {
        regionManager.RegisterViewWithRegion(
            RegionNames.SecondaryRegion, typeof(Views.HelloWorldView));
        regionManager.RegisterViewWithRegion(
            RegionNames.TestRegion, typeof(Views.TestTab));
       }
    }
}

需要哪些代码才能拥有多个选项卡,这些选项卡在 TestRegion 中的更改时显示动画。 我似乎无法弄清楚如何将任何内容绑定到 AnimatedTabControl 甚至常规选项卡控件...

I would love to use this, but cannot for the life of me figure out how to bind items to it.

I would like to see a simple example, something like

Shell.xaml

<Controls:AnimatedTabControl
   x:Name="TestTab"
   SelectedIndex="0"
   VerticalAlignment="Stretch"
   cal:RegionManager.RegionName="{x:Static inf:RegionNames.TestRegion}" 
   Grid.Row="1"  
/>

--

using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Regions;

namespace HelloWorldModule
{
    public class HelloWorldModule : IModule
    {
        private readonly IRegionManager regionManager;
        public HelloWorldModule(IRegionManager regionManager)
        {
            this.regionManager = regionManager;
        }

       public void Initialize()
       {
        regionManager.RegisterViewWithRegion(
            RegionNames.SecondaryRegion, typeof(Views.HelloWorldView));
        regionManager.RegisterViewWithRegion(
            RegionNames.TestRegion, typeof(Views.TestTab));
       }
    }
}

What code is needed to have multiple tabs that animate on change in TestRegion.
I cannot seem to figure out how to bind anything to AnimatedTabControl or even a regular tab control...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我乃一代侩神 2024-08-06 20:36:59

我认为您面临的问题是,当您实际上想要使用视图注入时,您正在使用视图发现。

使用视图发现,您可以将视图注册到某个区域,并且当该区域显示时,每个视图都会动态加载。 我的猜测是,您在该区域变得可见后向该区域注册视图。 这意味着您的视图永远不会被实例化,因为该区域已经变得可见。

视图注入动态地将视图插入到已经存在的区域中。 我想这就是你想做的。 您的 shell 很好,但您需要将以下内容添加到您的 Module Initialize() 调用中:

Views.HelloWorldView hello= new Views.HelloWorldView();
regionmanager.Regions[RegionNames.TestRegion].Add(hello);

这应该可以解决问题。

注意:您可以通过调用 IRegion 上的 Activate/Deactivate 方法来显示/隐藏某个区域中的视图,如下所示:

regionmanager.Regions[RegionNames.TestRegion].Activate(hello);

I think the problem you're facing is that you're using View Discovery when you actually want to use View Injection.

With View Discovery, you register views with a region and, when the region gets displayed, each of the views get dynamically loaded. My guess is that you're registering views with a region after the region has been made visible. This means that your views will never get instantiated as the Region has already been made visible.

View Injection dynamically inserts a view into an already existing region. I think this is what you want to do. Your shell is fine but you'll need to add the following to your Module Initialize() call:

Views.HelloWorldView hello= new Views.HelloWorldView();
regionmanager.Regions[RegionNames.TestRegion].Add(hello);

This should do the trick.

NB: you can show/hide views in a region by calling the Activate/Deactivate method on the IRegion like so:

regionmanager.Regions[RegionNames.TestRegion].Activate(hello);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文