Sort ItemsControl Prism v2.2 没有绑定集合的区域?

发布于 2024-09-30 15:12:44 字数 838 浏览 0 评论 0原文

有没有办法对添加到 ItemsControl 区域的视图进行排序?所添加的视图已注册到容器中,并添加到每个唯一模块中的区域中。

一些伪代码...

Shell:

<Window>  
   <ItemsControl Prism:RegionManager.Region="ItemsRegion"/>  
</Window>

模块:这是模块中的初始化代码。

protected override void RegisterViewsAndServices()
{
    CommonContainerLifetimeManager.Register<IView, ItemView1>();
    Container.RegisterType<IViewModel, ItemViewModel1>("ItemViewModel1");
}

public override void AdditionalInitialization()
{
    var itemView1 = Container.Resolve<ItemView1>();
    RegionManager.Regions["ItemsRegion"].Add(itemView1);
}

通过这种方法,它按照模块加载的顺序在 shell 的 itemscontrol 中显示添加的视图。根据登录用户的角色加载不同的模块。有没有一种方法,无需在中间添加集合,即可对视图视图模型的属性上的 itemscontrol.items 进行排序?有没有办法强制按一定顺序加载模块?我目前正在使用模块目录。

谢谢安迪

Is there a way to sort the views that get added to a ItemsControl region? The views being added are registered with the container and added to the region in each unique module.

Some pseudo code...

Shell:

<Window>  
   <ItemsControl Prism:RegionManager.Region="ItemsRegion"/>  
</Window>

Modules: This is the initialization code in the modules.

protected override void RegisterViewsAndServices()
{
    CommonContainerLifetimeManager.Register<IView, ItemView1>();
    Container.RegisterType<IViewModel, ItemViewModel1>("ItemViewModel1");
}

public override void AdditionalInitialization()
{
    var itemView1 = Container.Resolve<ItemView1>();
    RegionManager.Regions["ItemsRegion"].Add(itemView1);
}

With this approach it is showing the added views in the shell's itemscontrol in the order the modules are loaded. Based on the role of the logged on user different modules are loaded. Is there a way, without having to add a collection inbetween, to sort the itemscontrol.items on a property of the view's viewmodel for example? Is there a way to force the modules to be loaded in a certain order? I am currently using a module catalog.

Thanks

Andy

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

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

发布评论

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

评论(1

没有你我更好 2024-10-07 15:12:44

所以我找到了这个问题的答案...至少我在 Prism v4 中找到了答案。

您将 ViewSortHint 类属性添加到 View 的代码后面。 Prism 将找到此属性并根据您在 ViewSortHint 参数中输入的字符串对视图进行排序。

[ViewSortHint("01")]
public partial class SortedButton : UserControl
{
    public SortedButton()
    {
        InitializeComponent();
    }
}

希望这对某人有帮助......

安迪

So I found the answer to this question... At least I found the answer in Prism v4.

You add a ViewSortHint class attribute to the View's code behind. Prism will find this attribute and sort the views based upon the string you enter in the ViewSortHint parameter.

[ViewSortHint("01")]
public partial class SortedButton : UserControl
{
    public SortedButton()
    {
        InitializeComponent();
    }
}

Hope this helps someone...

Andy

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