2010-11-04 33 views
0

有沒有辦法對添加到ItemsControl區域的視圖進行排序?正在添加的視圖會在容器中註冊並添加到每個獨特模塊中的區域。Sort ItemsControl Prism v2.2沒有綁定集合的區域?

一些僞代碼...

殼牌:

<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); 
} 

通過這種方法被示出在模塊被加載的順序在所述殼的ItemsControl的附加視圖。根據登錄用戶的角色,加載不同的模塊。有沒有辦法,而不必增加一個集合,在視圖的viewmodel屬性上對itemscontrol.items進行排序,例如?有沒有辦法強制模塊以某種順序加載?我目前正在使用模塊目錄。

感謝

安迪

回答

0

所以我找到了這個問題的答案......至少我發現棱鏡V4答案。

您將ViewSortHint類屬性添加到View的代碼後面。 Prism會根據您在ViewSortHint參數中輸入的字符串查找此屬性並對視圖進行排序。

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

希望這可以幫助別人......

安迪

相關問題