<i:Icon/> in template will throw NullReferenceException when set Value
Flithor opened this issue · 1 comments
Flithor commented
ControlTemplate and DataTemplate are same.
Example code:
<ContentControl Content="ABCD">
<!--<ContentControl.Template>
<ControlTemplate TargetType="ContentControl">
<Button>
<StackPanel>-->
<!-- Throw NullReferenceException Here ↓-->
<!--<i:Icon Foreground="Black" Value="fas fa-times" />
<TextBlock Text="{TemplateBinding Content}"/>
</StackPanel>
</Button>
</ControlTemplate>
</ContentControl.Template>-->
<ContentControl.ContentTemplate>
<DataTemplate>
<Button>
<StackPanel>
<!-- Throw NullReferenceException Here ↓-->
<i:Icon Foreground="Black" Value="fas fa-times" />
<TextBlock Text="{Binding}"/>
</StackPanel>
</Button>
</DataTemplate>
</ContentControl.ContentTemplate>
</ContentControl>
Caused by this line:
`AvaloniaLocator.Current.GetService()' returns null.
Flithor commented