Conditional XAML
See original GitHub issueTo reduce load time or to increase layout performance one may need to conditionally detach layout controls from visual tree. For example, when layout part loads images from the Net, but a user has disabled image loading in the application settings, XAML layout does not need to load the view part responsible for image showing.
In Angular, there is a NgIf directive that solves this issue. So please, take a look: https://angular.io/api/common/NgIf
So, maybe Avalonia framework should have such control in its standard library? Something named AvalonIf that we can use in our application like this:
<AvalonIf Value="{Binding ShouldLoad, Mode=OneWay}">
<Image Source="{Binding Image, Mode=OneTime}"/>
</AvalonIf>
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:21 (20 by maintainers)
Top Results From Across the Web
Conditional XAML - UWP applications
It selectively parses elements or attributes to determine whether they will be available at runtime. Conditional statements are evaluated at ...
Read more >c# - Conditional XAML (WPF)
I am trying to create a User Control that, depending on the mode the user sets in the Dependency Property, changes the User...
Read more >Conditionals in XAML - Patrik Svensson
Ever wanted to display things conditionally in XAML based on a pre-processor directive like DEBUG ? Start by adding the following to your ......
Read more >Conditional XAML in UWP - YouTube
This tutorial explain about how to use the Conditional XAML concept in UWP.
Read more >Conditional XAML and x:Bind
Conditional XAML provides a way to use the ApiInformation.IsApiContractPresent method in XAML markup. This lets you set properties and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
UWP has build in x:DeferLoadStrategy attribute for lazy loading and x:Load attribute (Creators Update+) for loading and unloading with binding, which can replace UwpIf/AvaloniaIf
Or
@robloo, yes, it does.
It will be translated into IL code like:
Panel.Children.Add(IsOnAndroid() ? new ListBox() : new DataGrid())
which means only one “branch” will be executed and intialized.This, or users can use OnFormFactor which has Mobile or Default options, which is closer to what you asked.