MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit
MaterialDesignFlowDocument style missing?
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 16.3k
- Forks
- 3.5k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 8
Description
**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,
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the FlowDocumentScrollViewer example and inspect the existing MaterialDesignWindow and MaterialDesignTextBoxBase resources used in the issue's extension method. Determine where a FlowDocumentScrollViewer style belongs and verify that the example can reference MaterialDesignFlowDocument while retaining the expected theme colors and text styling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- design, desktop
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100