문제

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