MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit

MaterialDesignFlowDocument style missing?

未关闭
#3,275 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement up-for-grabs
主要语言
C#
星标
16.3k
派生
3.5k
平均合并
1 天 22 小时
30 天内合并 PR
8

描述

**Is your feature request related to a problem? Please describe.**
In order to get better performance compared to RichTextBox, I display a FlowDocumentScrollViewer with a binding to a FlowDocument of the ViewModel.
```


```

**Describe the solution you'd like**
I'd like a simple:
```


```

**Describe alternatives you've considered**
Here is the extension method dealing manually with style..
```
public static void AppendLogEvents(this FlowDocument flowDocument, IList logEvents)
{
var lastParagraph = flowDocument.Blocks.LastBlock as Paragraph;
if (lastParagraph == null)
{
lastParagraph = new Paragraph();
flowDocument.Blocks.Add(lastParagraph);
}

// Create a new style based on the MaterialDesignTextBoxBase style
var spanStyle = new Style(typeof(Span));
//spanStyle.BasedOn = (Style)Application.Current.Resources["MaterialDesignTextBoxBase"];
//spanStyle.Setters.Add(new Setter(TextElement.FontSizeProperty, 7.0));

var materialDesignSourceStyle = (Style)Application.Current.Resources["MaterialDesignWindow"]; //MaterialDesignTextBlock
var materialDesignSourceStyle2 = (Style)Application.Current.Resources[typeof(MaterialDesignExtensions.Controls.MaterialWindow)];
// Transfer all properties to spanStyle
foreach (Setter setter in materialDesignSourceStyle.Setters.Union(materialDesignSourceStyle2.Setters))
spanStyle.Setters.Add(new Setter(setter.Property, setter.Value));

foreach (var logEvent in logEvents)
{
// Render log message with a template
var renderedMessage = logEvent.RenderMessage();
var span = new Span(new Run(renderedMessage));
span.Style = spanStyle; // Apply the new style to the Span
if (logEvent.Level == LogEventLevel.Warning)
span.Foreground = Brushes.Orange;
else if (logEvent.Level == LogEventLevel.Error || logEvent.Level == LogEventLevel.Fatal)
span.Foreground = Brushes.Red;
else { } //NTD, will let light/dark mode fontcolor
lastParagraph.Inlines.Add(span);
lastParagraph.Inlines.Add(Environment.NewLine);
}
}
```

**Additional context**
Add any other context or screenshots about the feature request here.

Any thing I missed?
Feel free to recommend another approach!

Regards,

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 FlowDocumentScrollViewer 示例开始,检查 issue 的扩展方法中使用的现有 MaterialDesignWindow 和 MaterialDesignTextBoxBase 资源。确定 FlowDocumentScrollViewer 样式应放置的位置,并验证示例可以引用 MaterialDesignFlowDocument,同时保留预期的主题颜色和文本样式。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp
领域
design, desktop
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。