Answer the question
In order to leave comments, you need to log in
How to work with RichTextBox inside LongListSelector?
I use RichTextBox in LongListSelector like this:
<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>
ObservableCollection<ListItem> listItems = new ObservableCollection<ListItem>();
public MainPage()
{
InitializeComponent();
myLLS.ItemsSource = listItems;
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?
}
}
Answer the question
In order to leave comments, you need to log in
Through a self-written attached-property. Depending on the requirements, this can be a property with the string or Block types (a collection of Blocks). In the property change handler, the contents of RichTextBox.Blocks are filled with Blocks formed from the attached property.
And further in XAML:
<RichTextBox local:RichTextBinding.Source="{Binding Description}" ... />
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question