首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在LongListSelector中访问RichTextBox?

如何在LongListSelector中访问RichTextBox?
EN

Stack Overflow用户
提问于 2014-09-04 22:14:45
回答 1查看 38关注 0票数 0

我需要像这样在LongListSelector中使用RichTextBox:

代码语言:javascript
运行
复制
<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#代码:

代码语言:javascript
运行
复制
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。怎么做呢?

EN

Stack Overflow用户

发布于 2014-09-04 22:25:05

基本的=> http://wpftoolkit.codeplex.com/wikipage?title=RichTextBox&referringTitle=Home很难使用绑定来实现,但是ExtendedWpfToolkit创建了一个非常好的替代richtextbox

票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25667769

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档