- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在寻找一种在类似标签的控件中呈现短 FlowDocument
字符串的方法。
在 WPF 中,用户可以将文本输入到 RichTextBox
中。结果是一个 FlowDocument
字符串。我正在寻找一种在 Label
中显示该文本的方法,其中:
我有以下继承 FlowDocumentScrollViewer
的实现,但我确信必须有更好的实现(可能继承除 FlowDocumentScrollViewer
之外的其他控件)。
public class FlowDocumentViewer : FlowDocumentScrollViewer
{
public FlowDocumentViewer()
{
this.SetValue(ScrollViewer.CanContentScrollProperty, false);
this.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden);
this.Padding = new Thickness(-17);
this.Document = new FlowDocument();
}
protected override void OnMouseWheel(MouseWheelEventArgs e)
{
e.Handled = false;
}
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(FlowDocumentViewer), new UIPropertyMetadata(string.Empty, TextChangedHandler));
private static void TextChangedHandler(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue.Equals(string.Empty))
return;
FlowDocumentViewer fdv = (FlowDocumentViewer)d;
fdv.Document.Blocks.Clear();
using (MemoryStream stream = new MemoryStream(UTF8Encoding.UTF8.GetBytes(e.NewValue.ToString())))
{
Section content = XamlReader.Load(stream) as Section;
fdv.Document.Blocks.Add(content);
}
}
}
最佳答案
您是否尝试过设置 IsReadOnly?
<RichTextBox IsReadOnly="True"/>
关于c# - 如何在类似标签的控件中显示简短的只读 FlowDocument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1680461/
void main(){ char c; unsigned char uc; unsigned short us1, us2; short s1, s2; c
我要删除 wordpress html 格式在 woocommerce 产品简短描述中。添加 电话 到处标记。我知道如何在 wp 帖子和页面中做到这一点 remove_filter( 'the_exc
我通常会打开一个命令的联机帮助页,该命令已经知道我正在搜索的选项并阅读其描述。有时只需搜索该选项即可立即生效,有时该选项在其他地方被引用,有时该选项仅作为子字符串出现在前面的文本中。 作为一个具体的例
假设我们有一个编号的圆圈。我们想从 A 点到 B 点,但不知道应该向左还是向右。你会如何使用数字来计算你应该朝哪个方向前进? 示例: 我们目前在 1。我们想继续 5。我可以直观地看到 5 更近,所以我
我正在使用以下内容将产品名称和价格添加到悬停框。 在 functions.php 中 // Alter produt loop individual products add_action( 'woo
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我有一个for循环 for ($x=1; $x<=5; $x++){ ($x == 3)? continue : true; //some code here } 现在执行时出现错误
我刚刚开始我的第一个 Java Swing 项目(之前主要做基于 Web 的应用程序),并尝试了解如何构建一个适当的架构,并在 MVC 组件之间分离关注点。 我发现的几乎所有文档都非常深入地介绍了每个
我是一名优秀的程序员,十分优秀!