TabItem绑定问题 [英] TabItem binding issue

查看:99
本文介绍了TabItem绑定问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在标签项集合下面绑定到两个不同屏幕中的两个标签控件当我在屏幕之间切换标签控件没有显示任何标签项可以对此有任何帮助。



  private  ObservableCollection< TabItem> _leftContent =  new  ObservableCollection< TabItem>(); 

public ObservableCollection< TabItem> LeftContent
{
get { return _leftContent; }
set
{
_leftContent = value ;
RaisePropertyChanged( LeftContent);
}
}

解决方案

嗯,这很明显!您在两个地方使用相同的TabItem实例!



TabItem是一个控件,即UI而不是逻辑。



逻辑和UI之间的代码分离(例如MVVM)的想法可以帮助你:



对于每个TabItem:



1.包含包含其数据的View-Model。



2。每个TabControl(UI)实例创建一个新的TabItem实例(视图),但使用相同的View-Model实例。



我希望它有所帮助:)

I am binding below tab item collection to two tab controls in two different screen when i switch between the screens tab control does not show any tab items can any one help on this.

private ObservableCollection<TabItem> _leftContent = new ObservableCollection<TabItem>();

        public ObservableCollection<TabItem> LeftContent
        {
            get { return _leftContent; }
            set
            {
                _leftContent = value;
                RaisePropertyChanged("LeftContent");
            }
        }

解决方案

Well it's obvious! You are using the same instance of TabItem in two places!

TabItem is a Control, i.e. UI and not logic.

The idea of code separation between logic & UI (for example MVVM) can help you here:

For each TabItem:

1. Crate a View-Model containing his data.

2. Every TabControl (UI) instance, creates a new instance of TabItem (The View) but use the same View-Model instance.

I hope it helps :)


这篇关于TabItem绑定问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆