[英]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... 我正在尝试创建一个项目列表,并且这些项目包含多行信息-我使用的是列表框,并使用itemtemplate添加一个按钮,并使用数据模板将按钮的内容设置为多行文本,但是它没有用-只显示了两行。现在,我在做同样的事情,除了我没有使用按钮,而且我无法让文本行进入下一行...
Example: 例:
(didn't format correctly here - but each on a new line) Direction\\n TimePoint\\n Adherence (此处格式不正确-但每个格式都换了一行) 方向\\ n时间点\\ n坚持
Currently its doing: (no new lines) DirectionTimePointAdherence 当前正在执行:(无新行)DirectionTimePointAdherence
Here is the xaml...the binding is done in the code behind 这是xaml ...绑定是在后面的代码中完成的
<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" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.