András Tóth‘s professional blog
banditoth.net

Hey there 👋, I’m banditoth a .NET MAUI developer from Hungary.
I write about software development with .NET technologies.

You can find me on:
LinkedIn | Github | StackOverflow | X / Twitter | Threads

Tag: visual studio

  • Xamarin.Forms: Bindable Property snippet for Visual Studio

    This content has 4 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

    Use bprop tab tab to generate commands in ViewModels with this snippet

    The result of the snippet

    Save the snippet file as {name}.snippet in Visual Studio’s folder: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC#\Snippets\1033\Visual C#

    <?xml version="1.0" encoding="utf-8" ?>
    <CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    	<CodeSnippet Format="1.0.0">
    		<Header>
    			<Title>Bindable Property</Title>
    			<Shortcut>bprop</Shortcut>
    			<Description>Xamarin BindableProperty declaration code snippet</Description>
    			<Author>banditoth.hu</Author>
    			<SnippetTypes>
    				<SnippetType>Expansion</SnippetType>
    			</SnippetTypes>
    		</Header>
    		<Snippet>
    			<Declarations>
    				<Literal>
    					<ID>PropertyName</ID>
    					<ToolTip>The property's name</ToolTip>
    					<Default>Foo</Default>
    				</Literal>
    				<Literal>
    					<ID>Type</ID>
    					<ToolTip>The type of the property</ToolTip>
    					<Default>object</Default>
    				</Literal>
    				<Literal>
    					<ID>DefaultValue</ID>
    					<ToolTip>The default value of the property</ToolTip>
    					<Default>null</Default>
    				</Literal>
    				<Literal>
    					<ID>BindingMode</ID>
    					<ToolTip>The binding mode of the property</ToolTip>
    					<Default>TwoWay</Default>
    				</Literal>
    				<Literal>
    					<ID>PropertyChangedHandler</ID>
    					<ToolTip>The property changed handler method</ToolTip>
    					<Default>null</Default>
    				</Literal>
    				<Literal>
    					<ID>PropertyChangingHandler</ID>
    					<ToolTip>The property changing handler method</ToolTip>
    					<Default>null</Default>
    				</Literal>
    			</Declarations>
    			<Code Language="csharp">
    				<![CDATA[
            public static readonly BindableProperty $PropertyName$Property = BindableProperty.Create(
                                            propertyName: nameof($PropertyName$),
                                            returnType: typeof($Type$),
                                            declaringType: typeof(View),
                                            defaultValue: $DefaultValue$,
                                            defaultBindingMode: BindingMode.$BindingMode$,
                                            propertyChanged: $PropertyChangedHandler$,
    					propertyChanging: $PropertyChangingHandler$);
    
            public $Type$ $PropertyName$
            {
                get { return ($Type$)GetValue($PropertyName$Property); }
                set { SetValue($PropertyName$Property, value); }
            }
    		$end$]]>
    			</Code>
    		</Snippet>
    	</CodeSnippet>
    </CodeSnippets>
    
  • Xamarin.Forms: Lazy loaded Command snippet for Visual Studio

    This content has 4 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

    Use xamcomm tab tab to generate commands in ViewModels with this snippet

    IntelliSense recommendation

    Snippet in work

    Save the snippet file as {name}.snippet in Visual Studio’s folder: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC#\Snippets\1033\Visual C#

    <?xml version="1.0" encoding="utf-8" ?>
    <CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    	<CodeSnippet Format="1.0.0">
    		<Header>
    			<Title>Xamarin Lazy Command</Title>
    			<Shortcut>xamcomm</Shortcut>
    			<Description>Xamarin Command declaration code snippet for MVVM design pattern</Description>
    			<Author>banditoth.hu</Author>
    			<SnippetTypes>
    				<SnippetType>Expansion</SnippetType>
    			</SnippetTypes>
    		</Header>
    		<Snippet>
    			<Declarations>
    				<Literal>
    					<ID>BackFieldName</ID>
    					<ToolTip>Backfield Name</ToolTip>
    					<Default>_backfieldname</Default>
    				</Literal>
    				<Literal>
    					<ID>CommandName</ID>
    					<ToolTip>Command name</ToolTip>
    					<Default>CommandName</Default>
    				</Literal>
    				<Literal>
    					<ID>ActionToExecute</ID>
    					<ToolTip>Action to execute</ToolTip>
    					<Default>() => { return; /*TODO: Implement logic for this Command*/ }</Default>
    				</Literal>
            <Literal>
              <ID>ActionCanExecute</ID>
              <ToolTip>Action to determine can execute</ToolTip>
              <Default>() => true</Default>
            </Literal>
    			</Declarations>
    			<Code Language="csharp">
    			<![CDATA[
    	private Command $BackFieldName$Command;
    
    	public Command $CommandName$Command
    	{
    		get { return $BackFieldName$Command ?? ($BackFieldName$Command = new Command($ActionToExecute$,$ActionCanExecute$)); }
    	}
    	$end$]]>
    			</Code>
    		</Snippet>
    	</CodeSnippet>
    </CodeSnippets>
    
  • NuGet lokális Cache törlés egyszerűen

    This content has 5 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

    Amennyiben azt feltételezzük, hogy a Visual Studio a nugetek cachelése miatt nem működik úgy, ahogy az elvárt lenne, abban az esetben lehetőségünk van a lokális cache-t üríteni.

    GUI megoldás:
    ToolsOptionsNuGet Package ManagerPackage manager settings Clear All Nuget cache

    CLI megoldás:
    1. nuget.exe beszerzése – https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
    2. Parancs kiadása

    nuget locals all -clear
    
  • Xamarin iOS: Nem reagál az alkalmazás az értintésekre

    This content has 5 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

    Konzolban a hibaüzenet található, de az alkalmazás hiba nélkül kifordul, de az iOS 13.4.1-es verziót futtató eszközökön az érintések nem működnek.

    Hiba a konzolban:

    2020-04-12 15:25:09.177 PROJNAME.iOS[521:71276] &lt;_UISystemGestureGateGestureRecognizer: 0x283c60b00>: Touch: Failed to receive system gesture state notification before next touch
    2020-04-12 15:25:09.177 PROJNAME.iOS[521:71276] &lt;_UISystemGestureGateGestureRecognizer: 0x283c60900>: Gesture: Failed to receive system gesture state notification before next touch
    
    

    Megoldás: Visual Studio for Mac 8.5.1-es verzióról (vagy ennél kisebb verzióról) fel kell frissíteni a MacVS-t, a Windowsos verzójában a hiba a 16.5.2-től lett orvosolva.

    https://github.com/xamarin/Xamarin.Forms/issues/10162

  • Multilingual App Toolkit build fail Visual Studio Mac-en

    This content has 5 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.
    ProjectName is Multilingual build enabled, but the Multilingual App Toolkit is unavailable during the build
    

    Mivel a Mac-es VS-hez nincs Multilingual App Toolkit, ezért ideiglenesen ki kell kapcsolni a buildből a Toolkitet. Ezt a solution unloadolásával tehetjük meg, majd szerkesztjük a .csproj fájlt a következőek szerint:

    A fájl végén található Import tageket ki-XML-kommentezzük:

    <!-- <Import Project="$(MSBuildExtensionsPath)\Microsoft\Multilingual App Toolkit\Microsoft.Multilingual.ResxResources.targets" Label="MultilingualAppToolkit" Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\Multilingual App Toolkit\v$(MultilingualAppToolkitVersion)\Microsoft.Multilingual.ResxResources.targets')" /> -->
      <!-- <Target Name="MATPrerequisite" BeforeTargets="PrepareForBuild" Condition="!Exists('$(MSBuildExtensionsPath)\Microsoft\Multilingual App Toolkit\Microsoft.Multilingual.ResxResources.targets')" Label="MultilingualAppToolkit">
        <Warning Text="$(MSBuildProjectFile) is Multilingual build enabled, but the Multilingual App Toolkit is unavailable during the build. If building with Visual Studio, please check to ensure that toolkit is properly installed." />
      </Target> -->