我是新來WPF使用兩個代碼的ViewModels在XAML請幫我任何one.i有兩個的ViewModels 1.ItemCategoryViewModel和2.TypeViewmodel這兩種視圖模式來不同的兩個表如何使用TabControl的
<tabcontrol>
<TabItem x:Name="itemtype" Header="ItemType" IsSelected="True" MinHeight="10">
<Grid/>
</tabitem>
<TabItem Header="ItemCategory" Margin="-1,0" MinHeight="10">
<grid/>
</tabitem>
</tabcontrol>
在xaml.cs代碼中,我想使用兩個viewmodels。
TypeViewmodel povm = new TypeViewmodel();
ItemCategoryViewModel tcvm=new ItemCategoryViewModel();
public PurchaseOrderEntry()
{
InitializeComponent();
this.DataContext = povm;
this.DataContext = tcvm;
txtPONumber.Focus();
if (povm.FocusMoveTo == null)
povm.FocusMoveTo = new Action(() => this.FieldNumberToChange());
if (povm.FocusMoveByTabId == null)
povm.FocusMoveByTabId = new Action(() =>this.GoToFocusByTabId());
if (povm.OpenDialogue == null)
povm.OpenDialogue = new Action<string>(this.OpenDialogue);
if (tcvm.FocusMoveTo == null)
tcvm.FocusMoveTo = new Action(() => this.FieldNumberToChange());
if (tcvm.FocusMoveByTabId == null)
tcvm.FocusMoveByTabId = new Action(() =>this.GoToFocusByTabId());
if (tcvm.OpenDialogue == null)
tcvm.OpenDialogue = new Action<string>(this.OpenDialogue);
}
當我只執行一個標籤項執行另一個不working.viewmodel重寫。我如何解決請幫助我
太感謝你了,但我怎麼寫XmaI和xaml.cs,有沒有在XAML –
任何改變,我會編輯我的回答你,讓它變得更清晰,好嗎? – TripleEEE
這是否幫助你,還是你需要更詳細的幫助? – TripleEEE