开发者

Displaying a list of Items in a WPF form using XAML

开发者 https://www.devze.com 2022-12-27 14:05 出处:网络
I am attempting to display a list of items (the style and controltemplate for these items are defined elsewhere) and i want to be able to add/remove as many as i want to. As i do not have infinite scr

I am attempting to display a list of items (the style and controltemplate for these items are defined elsewhere) and i want to be able to add/remove as many as i want to. As i do not have infinite screen realestate I am displaying these in a ListBox control.

This is the screen i have to date:

Displaying a list of Items in a WPF form using XAML

What is going to happen is this. When i click the New button, i want the item to appear in the outlined area.

So now for the problem:

I want, when i click the New... Button, a new item to appear in the ListBox (outlined). Is it possible to do this using XAML? I am trying to work on seperating the business logic from the interface, so if there were some way to acheive this in XAML i would appreciate it. If not,can i use the custom templated item i have created i开发者_开发技巧n C# so that it will appear as the template specifies in the list box instead of like a normal ListBoxItem

Thanks in advance!


I think the only way to achieve this is to add the new (empty) item to the list to which the outlined listview is databound.

If there's any business logic involved in creating the new item you should ask your business logic layer to create the new item for you, otherwise instantiate the object as you would normally do.


you can use ObesrvableCollection for this purpose. Use twoway binding to show the details should be displayed in the list while typing.

0

精彩评论

暂无评论...
验证码 换一张
取 消