Displaying a list of Items in a WPF form using XAML
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:
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.
精彩评论