Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - ListBox ItemTemplate Wrapping and others

 
 
Old 11-07-2006   #1 (permalink)
Jan Kucera


 
 

ListBox ItemTemplate Wrapping and others

Hi all, I have the following troubles with my first xaml application and I
would welcome any advices on them....

I have a xml with items like:
<items>
<SectionID>29</SectionID>
<Title>Mezinárodní grant AVMEDIA-SMARTBOARD</Title>
<Preamble>
very long line of text
next line of text


</Preamble>
<Time>2005-01-16 16:23:52</Time>
</items>

and I'm populating the ListBox using:

<ListBox Name="ObjectList" ItemsSource="{Binding Source={StaticResource
xmlItems}, XPath=/VeskoleOffline/items}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock>
<TextBlock Text="{Binding XPath=Title}" FontWeight="Bold"></TextBlock>
<TextBlock Text="{Binding XPath=ModifiedTime}" Foreground="Blue"
FontStyle="Italic" TextAlignment="Right"></TextBlock>
</TextBlock>
<TextBlock Text="{Binding XPath=Preamble}" Foreground="Gray"
Padding="16,0,0,8" TextWrapping="Wrap"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

Now, the problems:
UI:
1) The ModifiedTime is not at the right side.
2) The Preamble is not wrapped. There is a long long line and the listbox
have a horizontal scrollbar
I believe these are because of my bad design. How should I work within the
DataTemplate? How to wrap the text at the width of the listbox?

3) How should I parse the ModifiedTime value and display formated output of
DateTime? Can it be done in XAML?

Data:
4) The contents of Preamble is as it is in xml source with whitespace, that
means in this case with the last two empty rows. How should I tell the
XmlDataProvider (or the text container) to ignore WhiteSpace?
5) How can I modify the ListBox.ItemsSource XPath?
The simpler case: I have a TreeView populated from another xml document
with section names. I want the ListBox to display only the items with
SectionID={the one selected in the treeview}. I believe this could be done
in XAML, couldn't it? - on treeview selected node changed.
The worse case: I have a text box for searching, so on text change, I
would like to update the XPath to something like
/VeskoleOffline/items/Title[contains(.,'{textbox text}')]. I'm afraid this
is not possible in XAML, right? But in code I don't know how to access the
XPath property...

And the last thing, If I would like to highlight the search pattern like
in Outlook 2007, or... to detect and make http or e-mail address active...
any idea? In HTML, I would use regular expressions to enclose the match in
appropriate tag.

Many thanks for any little help or idea,
Jan


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Mouse wrapping Software
Easy to get handle from listbox. How to get listbox from handle? .NET General
how to get rid of line wrapping in powershell PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46