简体   繁体   中英

WPF design & binding

I have a WPF application. I have a custom object that contain a list. The list is a custom type of "Order", the list contains 24 items. The list contains three properties. First property "baseCurrency" (ie GBP) of type string, second property "orderCurrency" (ie JPY) of type string & the third property "calculate" of type boolean.

In my WPF application I have a grid that is split into 24 equal size squares. In each square I want a control that contains a textbox and two small icon images. I want the textbox to be bound to the two string properties for an item from my list. The two small icon images are flags. So if we have GBP & JPY the two images would be their respective flags. I also want to bind the images based on the string provided. So if GBP is selects the gbp.jpn image in my project folder - not sure how I do this?

I'm think of using a toggle button as my control that will contain the textbox and images. I hoping to bind each button to a list item. The calculate property will be bound to the toggle button IsChecked property. If IsChecked is true I want my calculate property to be true.

Is there a better control that I should be using rather than a toggle button? Is there also a better way of trying to accomplish what I'm after?

Your situation is so common that the MVVM pattern is widely used in WPF for that purposes. To get started, you may read about:

There is also a post on my blog related to working with currency in WPF application

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM