【问题标题】:Data Binding to another .cs file数据绑定到另一个 .cs 文件
【发布时间】:2016-03-09 09:06:41
【问题描述】:

在 Wpf 中,我想为列表框分配一个宽度,其中 Width 应该绑定到一个方法,使用的是另一个 cs 文件中的 RelativeSource Templated Parent Method。

我尝试过使用

Width={Binding Path=ActualWidth, ParentedElementName}

但它不起作用。

我必须根据该方法改变列表框的宽度。我该怎么做?

【问题讨论】:

  • 添加价值 1000 字的代码。

标签: wpf data-binding listboxitem


【解决方案1】:

我认为您必须在后面的代码中设置DataContext 属性。尽管让 ViewModel 处理问题可能比让 View 从不同的地方收集数据更好。

【讨论】:

    猜你喜欢
    • 2010-10-16
    • 2011-06-27
    • 2013-02-05
    • 1970-01-01
    • 2016-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多