[英]Multiple instances of UserControl in WPF MVVM application
I have a requirement ie one view should have multiple instances at runtime for loading data of different employees from an Xml file eg employee form for creating a new employee details and loading from xml file. 我有一个要求,即一个视图在运行时应具有多个实例,以便从Xml文件中加载不同员工的数据,例如,用于创建新员工详细信息并从xml文件加载的员工表单。 I did some search on google and found a very useful link http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
我在Google上进行了一些搜索,发现了一个非常有用的链接http://msdn.microsoft.com/zh-cn/magazine/dd419663.aspx
For a WPF MVVM application, it is perfect when multiple instances of the ViewModel are created the view reciprocates. 对于WPF MVVM应用程序,当视图往复创建多个ViewModel实例时,这是完美的选择。 The only problem I see is when I place the text box control with
TabControl
TabItem
ie when I select a particular tab item with in Tab control the other instances of the view reciprocate the same way. 我看到的唯一问题是当我使用
TabControl
TabItem
放置文本框控件时,即当我在Tab控件中选择特定的选项卡项目时,视图的其他实例也以相同的方式往复运动。 How do I prevent the application from doing this? 如何防止应用程序执行此操作? Is there a property of
TabItem
which could be bound? 是否有可以绑定的
TabItem
属性?
If any one has similar issue the solution is to bind SelectedTabGridIndex
to RadTabItem
. 如果有类似问题,解决方案是将
SelectedTabGridIndex
绑定到RadTabItem
。
private int _selectedTabGridIndex;
public int SelectedTabGridIndex
{
get { return _selectedTabGridIndex; }
set
{
if (value == _selectedTabGridIndex)
return;
_selectedTabGridIndex = value;
base.OnPropertyChanged("SelectedTabGridIndex");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.