我需要像这样在LongListSelector中使用RichTextBox:
<phone:LongListSelector Name="myLLS">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Name}" />
<TextBlock Text="{Binding Surname}" />
<RichTextBox IsReadOnly="True" />
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>C#代码:
ObservableCollection<ListItem> listItems = new ObservableCollection<ListItem>();
public MainPage()
{
InitializeComponent();
myLLS.ItemsSource = trainStations;
listItems.Add(new ListItem("John", "Smith", "Some big and formatted text 1"));
listItems.Add(new ListItem("Bill", "Dixon", "Some big and formatted text 2"));
listItems.Add(new ListItem("Ralph", "Watson", "Some big and formatted text 3"));
}
public class ListItem
{
private string _name;
private string _surname;
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Surname
{
get { return _surname; }
set { _surname = value; }
}
public ListItem(string name, string surname, string description)
{
this.Name = name;
this.Surname = surname;
// How to set content to my RichTextBox here?
}
}在这里使用TextBlock是没有问题的。但是我需要将description的文本设置为RichTextBox。怎么做呢?
发布于 2014-09-04 22:25:05
基本的=> http://wpftoolkit.codeplex.com/wikipage?title=RichTextBox&referringTitle=Home很难使用绑定来实现,但是ExtendedWpfToolkit创建了一个非常好的替代richtextbox
https://stackoverflow.com/questions/25667769
复制相似问题