question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting TextBox FontFamily property from Style causes XamlObjectWriterException

See original GitHub issue
<Style Selector="TextBox.export">
    <Setter Property="FontFamily" Value="Consolas"/>
</Style>

version: 0.7.1-build989-beta

Portable.Xaml.XamlObjectWriterException
  HResult=0x80131500
  Message=Set value of member '{clr-namespace:Avalonia.Styling;assembly=Avalonia.Styling}Setter.Value' threw an exception
  Source=Avalonia.Markup.Xaml
  StackTrace:
   at Portable.Xaml.XamlObjectWriterInternal.SetValue(XamlMember member, Object target, Object value)
   at Portable.Xaml.XamlObjectWriterInternal.SetValue(XamlMember member, Object value)
   at Portable.Xaml.XamlObjectWriterInternal.OnWriteEndMember()
   at Portable.Xaml.XamlWriterInternalBase.WriteEndMember()
   at Portable.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.LoadFromReader(XamlReader reader, AvaloniaXamlContext context, IAmbientProvider parentAmbientProvider)
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(Stream stream, Assembly localAssembly, Object rootInstance, Uri uri)
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(Type type, Object rootInstance)
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(Object obj)
   at ThemeEditor.App.Initialize() in C:\DOWNLOADS\GitHub\ThemeEditor\src\ThemeEditor\App.xaml.cs:line 10
   at Avalonia.Controls.AppBuilderBase`1.Setup()
   at Avalonia.Controls.AppBuilderBase`1.Start[TMainWindow](Func`1 dataContextProvider)
   at ThemeEditor.Program.Main(String[] args) in C:\DOWNLOADS\GitHub\ThemeEditor\src\ThemeEditor\Program.cs:line 19

Inner Exception 1:
NullReferenceException: Object reference not set to an instance of an object.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
Gillibaldcommented, Jan 6, 2019

I guess you could define the font family in code by defining a static property and reference it in your style.

0reactions
arun-katcommented, Sep 5, 2019

I also see the same issue as MiKaMaru with the Button control.

I’m able to set the other properties using the syntax below, but I get the error: “NullReferenceException: Object reference not set to an instance of an object.” for the FontFamily line.

<Style Selector="Button">
  <Setter Property="Background" Value="LightGray"/>
  <Setter Property="FontSize" Value= "12"/>
  <Setter Property="BorderThickness" Value= "1"/>
  <Setter Property="BorderBrush" Value= "#6C6F70"/>
  <Setter Property="FontFamily" Value ="Arial"/>
</Style>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change FontFamily for Textbox while defined in ...
It is working for me. I defined two styles, one for window, one special for text box. Special style wins and result is...
Read more >
TextBlock.FontFamily Property (System.Windows.Controls)
The following example shows how to set the FontFamily property programmatically. C# Copy. TextBlock textBlock = new TextBlock(new Run("A bit of text content ......
Read more >
HTML DOM Style fontFamily Property
Style fontFamily Property ... Set the font for an element: ... The fontFamily property sets or returns a list of font-family names and/or...
Read more >
Styling type on the web with variable fonts
Whether loading variable fonts from a font delivery service or our own server, ... Let's assign a variable weight property to some of...
Read more >
How To Style Text Elements with Font, Size, and Color in ...
You also set up a font-family property that applies specifically to heading text content. In the next section you will use the Google...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found