Click here to Skip to main content
15,032,177 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi Friends,

I have an xml document as below.

< Student >
    ...
    < Phone >111 < /Phone >
    < Phone >111 < /Phone >
    < Phone >111 < /Phone>
    < Phone >111 < /Phone>
    ...
< /Student>


I need to display all the Phone entries in some UI. I can easily do this by binding a WPF ListView with Phone entries.

But I don't want to use WPF ListView for this. Instead I want a user control just like the TO, CC and BCC text boxes we have in Yahoo or Hotmail email account. You can see in Yahoo or Hotmail email account that while sending an email, they show each email address in separate boxes. I can't attach a snapshot here so please log-in your account to see the exact behavior I want. Can somebody help me about how to create a user control like those text boxes? Or if there are some links from where I can get the direction about creating them. Please help me.

Some more detail:
I am able to create a user control as I asked above by using a ListBox with data template as shown below:

<ListBox.ItemsPanel>
    <ItemsPanelTemplate>
        <WrapPanel/>
    </ItemsPanelTemplate>
</ListBox.ItemsPanel>


But the problem is that I also want to give a text box after last item in WrapPanel. From above ItemTemplate you can observe that all the items in ListBox will be drawn in a WrapPanel and so they will wrap. But how can I add one text box after the last Item so that user can enter some text and as soon as he press Enter key,a new ListBoxItem gets created. Actually what I want here is difficult to explain as I cannot attach any image here for better explanation. So please see TO, CC and BCC text boxes in Yahoo or Hotmail email account.

I also want to add something here. When I tried with following changes, I got an exception. The exception is that since WrapPanel is being filled dynamically (as ListBox has been bind with xml nodes as I did explain in previous post), you cannot add anything (like I am adding a TextBox here) statically.

<ListBox.ItemsPanel>
    <ItemsPanelTemplate>
        <WrapPanel>
            <TextBox Text="Default Text" />
        </WrapPanel>
    </ItemsPanelTemplate>
</ListBox.ItemsPanel>


Please help me.

Regards
Aseem.
Posted
Updated 13-Mar-12 20:49pm
v3
Comments
Sridhar Patnayak 13-Mar-12 8:15am
   
Pretags added
Aseem Sharma 14-Mar-12 2:50am
   
I have improved my question with some more explanation. Please see :"Some More Detail" section to understand my problem.
   
It's hard to understand what exactly you are missing. Such UI looks pretty straightforward; everything you need is available in WPF. Maybe you try to design and implement it, and then ask more specific questions if and when you face some problems.

Otherwise the only answer would be detail explanation of design and implementation, nearly the same as writing the whole code for you, because there are no any very special ideas or tricks here, but that hardy may happen...

--SA
Aseem Sharma 14-Mar-12 2:51am
   
I have improved my question with some more explanation. Please see :"Some More Detail" section to understand my problem.

1 solution

Hello

I think it can help you:

http://stackoverflow.com/questions/2087327/wpf-usercontrol-textbox-propertychanged-event-not-firing[^]

Read the both of "question" and "the first answer".
   
v2
Comments
Aseem Sharma 14-Mar-12 2:51am
   
I have improved my question with some more explanation. Please see :"Some More Detail" section to understand my problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900