【问题标题】:Wpf Combo SelectionWpf 组合选择
【发布时间】:2010-12-02 16:41:16
【问题描述】:

我遇到了 WPF 组合框的问题。

我像这样在我的 Combo 上绑定一个 List >(目的地):

我的pair类是这样定义的:

/// <summary>
/// This class represents a pair.
/// </summary>
public class Pair<T, U>
{
    #region Properties

    /// <summary>
    /// Gets or sets the first value.
    /// </summary>
    public T First 
    { 
        get; 
        set; 
    }

    /// <summary>
    /// Gets or sets the second value.
    /// </summary>
    public U Second 
    { 
        get; 
        set; 
    }

    #endregion

    #region Methods

    /// <summary>
    /// Default constructor
    /// </summary>
    public Pair()
    {
    }

    /// <summary>
    /// Constructor by initialization.
    /// </summary>
    /// <param name="pFirst">The first value.</param>
    /// <param name="pSecond">The second value.</param>
    public Pair(T pFirst, U pSecond)
    {
        this.First = pFirst;
        this.Second = pSecond;
    }

    #endregion
};

我试图仅将我的对的第二个属性显示为我的组合的显示。我试过了:

DisplayMemberPath={Binding Destinations.Second} 但它不起作用。

感谢您的回答。

【问题讨论】:

    标签: wpf


    【解决方案1】:
    DisplayMemberPath="Second"
    

    这应该可以工作,因为每个项目都是Pair

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-03
      • 1970-01-01
      • 2021-11-16
      • 2013-12-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多