简体   繁体   中英

data templates wp7/8

I am trying to create a list of items and the items consist of multiple lines of information - I was using a listbox and used the itemtemplate to add a button and set the contents of the button as the multiple lines of text using a data template but it did not work - only 2 lines showed.Now, I am doing the same thing except I am not using the button and I cannot get the lines of text to go on the next line...

Example:

(didn't format correctly here - but each on a new line) Direction\\n TimePoint\\n Adherence

Currently its doing: (no new lines) DirectionTimePointAdherence

Here is the xaml...the binding is done in the code behind

 <ListBox Name="listBox_1"  Background="Transparent" Margin="0,125,0,0" VerticalAlignment="Top">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" Height="100">
                                    <TextBlock FontSize="28" Foreground="#FF348F8F" Text="{Binding Direction}" Height="40"/>
                                    <TextBlock FontSize="28" Foreground="White" Text="{Binding TimePoint}" Height="40"/>
                                    <Grid Background="#FFE3EFFF">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <StackPanel Orientation="Vertical" Height="40" Margin="-2,0,0,0">
                                            <TextBlock FontSize="28" Foreground="White" Text="{Binding Adherence}" Height="40"/>
                                        </StackPanel>
                                    </Grid>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox> 

wrap your text. it might do the trick :

<TextBlock TextWrapping="Wrap" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM