Coder Social home page Coder Social logo

Comments (6)

ZH-UCAS avatar ZH-UCAS commented on May 29, 2024

我的结构 public class ComplexInfoModel : ObservableObject
{
private String key;

    /// <summary>
    /// Key值
    /// </summary>
    public String Key
    {
        get { return key; }
        set { key = value; RaisePropertyChanged(() => Key); }
    }

    private String text;

    /// <summary>
    /// Text值
    /// </summary>
    public String Text
    {
        get { return text; }
        set { text = value; RaisePropertyChanged(() => Text); }
    }

    private String boxText;

    /// <summary>
    /// Text值
    /// </summary>
    public String BoxText
    {
        get { return boxText; }
        set { boxText = value; RaisePropertyChanged(() => BoxText); }
    }
}

from panuonui.

Mochengvia avatar Mochengvia commented on May 29, 2024

BindingItems属性只能设置为ObservableCollection<PUComboBoxItemModel>类型,不能像ItemsSource属性那样设置为其他类型的集合(并且ItemsSource属性也不能适用于此控件,下一个版本将隐藏它)。
你需要将集合转化为ObservableCollection<PUComboBoxItemModel>,Header设置为你的Text属性,Value设置为你的Key属性,并将PUComboBox的SelectedValuePath属性设置为Value即可。
image
如上图所示。
这时SelectedValue的值就是Value属性了。

今天(11.28日)修复了BindingItems属性的一些问题(与本问题无关),在使用之前建议先更新一下。

from panuonui.

ZH-UCAS avatar ZH-UCAS commented on May 29, 2024

好的谢谢 但是我有三个以上属性时就需要修改 PUComboBox的cs文件是这样吗~
需要对应传递值给他们

from panuonui.

Mochengvia avatar Mochengvia commented on May 29, 2024

除了改cs文件之外,也可以选择把两个集合都保留下来——当用户点击确定按钮的时候,根据当前的SelectedValue去你原先的集合中找对应的条目,来获取内容。目前只有这两个方法,我说的这个方法更适合于扩展,当然直接修改cs也不是不行

from panuonui.

Mochengvia avatar Mochengvia commented on May 29, 2024

啊对了,另一个可行的办法就是把Value属性设置为你的单个ComplexInfoModel对象,这样选择的实际SelectedValue就是你的对象了。

from panuonui.

ZH-UCAS avatar ZH-UCAS commented on May 29, 2024

好的吧 我明天会进行尝试谢谢

from panuonui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.