文本框在前看不见的价值 - 视图模型绑定到一个选项卡(内容控制) [英] Value of text box disapears - binding viewmodel to a tab (content control)

查看:137
本文介绍了文本框在前看不见的价值 - 视图模型绑定到一个选项卡(内容控制)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

,我已经实现结合到不同的标签,不同的视图模型的多标签选项 用一个简单的DataTemplate结合一个视图模型到视图。

Based on the MVVM example by Josh Smith, I have implemented the multi tab option which binds to a different tab to a different view model using a simple datatemplate that binds a viewmodel to a view.

 <DataTemplate  DataType="{x:Type fixtureVM:SearchViewModel}">
    <SearchVw:SearchView/>
</DataTemplate>

这是我遇到的问题是,当我切换选项卡,然后再切换回来,在文本框中的值消失。当我在文本框中的文本绑定到一个值,在视图模型它不会消失。这是好的,我可以克服这一点,但我有另外一个问题,例如用在网格滚动条消失,一旦标签已失去焦点的位置。

The issue that I'm having, is when I switch tabs and then switch back again, the value in the textbox disappears. When I bind the Text in the textbox to a value in the ViewModel it does not disappear. This is fine, and I can overcome this but I am having another issue for example with the position of the scroll bar in a grid disappearing once the tab has lost focus.

为什么值消失?我假设它是清理资源WPF子系统的任务!?我怎样才能避免这种情况?我也觉得它可能会放慢我的应用程序。

Why is the value disappearing? I'm assuming it is a WPF sub system task that cleans up resources!? how can I avoid this? I also feel it might be slowing down my app.

推荐答案

下面是创建的TabControl的一个子类的解决方案。

Here is a solution that creates a subclass of the TabControl.

http://eric.burke.name/dotnetmania/2009/ 4月26日/ 28年9月22日

这篇关于文本框在前看不见的价值 - 视图模型绑定到一个选项卡(内容控制)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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