Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Forms XAML Design Instance

Is there a way to enable design context in Xamarin Forms XAML pages to enable intellisense? It works in WPF but for years I couldn't get it to work in Xamarin Forms.

like image 875
Christopher Richmond Avatar asked Jul 28 '26 10:07

Christopher Richmond


1 Answers

So if you compile your xaml by setting the attribute in code somewhere, and then include the xaml snippet below, you can use design time data contexts and get the intellisense.

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
namespace MySpace
{
   public partial class App {}  
}

<Page
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d ="http://schemas.microsoft.com/expression/blend/2008" 
mc:Ignorable="d"             
d:DataContext="{d:DesignInstance Type=list:TestViewModel}"
xmlns:list="clr-namespace:PolyhydraGames.Test.ViewModels"
.../>
like image 88
Christopher Richmond Avatar answered Jul 31 '26 22:07

Christopher Richmond



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!