I want the controls in my wpf window to change depending on whether the user is viewing or editing/inserting data. For example, I want to display a label at view time, but a text box (or combo box etc) at edit/insert time.

Can I do this with DataTemplates or do I have to have two controls for each data item and change visibility depending on what mode the form is in?

If DataTemplates will do the job, can anybody point me to some examples?

many thanks mcalex

有帮助吗?

解决方案

In my opinion, the better way to do this is using differrent data templates for control, in case when you always need to use them together. In any case you have to select switch templates or controls mechanism. You can use DataTrigger (first answer) or ValueConverter

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top