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.

When trying to have multiple styles the Program throws exception

See original GitHub issue

Describe the bug When I have multiple styles inside <Window.Styles> Avalonia throws and exception

To Reproduce

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
		xmlns:gif="clr-namespace:AvaloniaGif;assembly=AvaloniaGif"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
		MinWidth="800" MinHeight="450"
		Width="800" Height="450"
        x:Class="AnimationTest.MainWindow"
        Title="AnimationTest">
	<Window.Styles>
		<Style Selector="Image#intro">
			<Setter Property="Width" Value="5"/>
			<Setter Property="Height" Value="5"/>
			<Style.Animations>
				<Animation Delay="0:0:1" Duration="0:0:2">
					<KeyFrame Cue="0%">
						<Setter Property="Width" Value="800"/>
						<Setter Property="Height" Value="450"/>
					</KeyFrame>
					<KeyFrame Cue="100%">
						<Setter Property="Height" Value="5"/>
						<Setter Property="Width" Value="5"/>
					</KeyFrame>
				</Animation>
			</Style.Animations>
		</Style>
		<Style Selector="Grid#grd_test">
			<Style.Animations>
				<Animation Delay="0:0:1" Duration="0:0:2">
					<KeyFrame Cue="0%">
						<Setter Property="Opacity" Value="0.0"/>
					</KeyFrame>
					<KeyFrame Cue="100%">
						<Setter Property="Opacity" Value="1.0"/>
					</KeyFrame>
				</Animation>
			</Style.Animations>
		</Style>
	</Window.Styles>
	<Grid Name="grd_intro" MinWidth="1">
		<Image Name="intro" Grid.Column="1"
               Stretch="UniformToFill"
               gif:GifImage.SourceUriRaw="resm:AnimationTest.Assets.intro.gif" gif:GifImage.IterationCount="0"/>
	</Grid>
	<Grid Name="grd_test">
	</Grid>
</Window>

Exception XAMLIL Unable to find a setter that allows multiple assignments to the property Content of type Avalonia.Controls:Avalonia.Controls.ContentControl Line 1, position 2. AnimationTest C:\Users\user\source\repos\AnimationTest\AnimationTest\MainWindow.axaml

Desktop (please complete the following information):

  • OS: Windows 10
  • Version Avalonia v0.10.0, .NET 5

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jp2masacommented, Feb 2, 2021

I think the problem here is that the Window has 2 children, as stated by the error.

0reactions
WakanaYukicommented, Feb 2, 2021

@jp2masa Thank you so much, that was actually the issue, I totally forgot that I have 2 grids in the MainWindow. I was way too focused on the <Style Selector="######"> part…

Read more comments on GitHub >

github_iconTop Results From Across the Web

In Java, is using throws Exception instead of ...
No, absolutely not. You should specify what exceptions you're going to throw so the caller can do the right thing with each one....
Read more >
Why shouldn't a method throw multiple types of checked ...
Declaring a method to throw too many differently rooted exceptions makes exception handling onerous and leads to poor programming practices such ...
Read more >
Best Practices for exceptions - .NET
Learn best practices for exceptions, such as using try/catch/finally, handling common conditions without exceptions, and using predefined .
Read more >
Types of Exceptions in Java
Learn about the different types of exceptions in Java (checked and unchecked) and see specific examples.
Read more >
How to Throw Exceptions in Java
When exceptions are thrown, they may be caught by the application code. The exception class extends Throwable . The constructor contains two ......
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