WPF中viewmodel层怎样得到view层的TabControl控件对象?

View层:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

。。。。

 cal:Message.Attach="[Event Loaded]=[Action WindowLoaded(A.Tag)]">  

。。。。

<TabControl x:Name="A" Tag="{Binding RelativeSource={RelativeSource Self}}" Grid.Row="3" Grid.Column="1" Grid.RowSpan="4" Width="700" Height="380">
<TabItem Header="库存明细">

</TabItem>
<TabItem Header="已选商品">

</TabItem>

。。。。

ViewModel层:

public void WindowLoaded(object sender)//窗体加载的方法
{
TabControl tc = (TabControl)sender;//得到控件对象并操作它
tc.Items.RemoveAt(0);
}

注:必须要写黄色区域的代码

上一篇:Struts自定义拦截器&拦截器工作原理


下一篇:在linux中混合汇编和C的编程