【发布时间】:2016-09-26 21:06:59
【问题描述】:
问题
我有一个绑定到 ObservableCollection 的 Listbox:
Polls = new ObservableCollection<string>();
DataSet LoadAllPolls = _publisher.GetQuizFeatures(Global.gEpisodeWS.Id);
foreach (DataRow item in LoadAllPolls.Tables[0].Rows)
{
Polls.Add(item["Description"].ToString());
}
这是 XAML:
<ListBox x:Name="lb_polls" Background="#ececec" BorderBrush="Transparent" SelectedItem="{Binding SelectedPoll}" ItemsSource="{Binding Polls}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Height" Value="110"/>
<Setter Property="Width" Value="200"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#858585" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#858585" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="#858585"/>
</ListBox.Resources>
</ListBox>
现在我希望将添加到 ListBox 项的字符串换行。我该怎么做?
【问题讨论】: