Skip to content

Instantly share code, notes, and snippets.

View jpd21122012's full-sized avatar
:octocat:

Ing. Jorge Perales Díaz jpd21122012

:octocat:
View GitHub Profile
// Create scope explicitly
using (var scope = Services.CreateScope())
{
var dbService = scope.ServiceProvider.GetRequiredService<IDbService>();
// All resolved services share the same scope
}
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
// Core MAUI services
builder.UseMauiApp<App>()
.ConfigureFonts(fonts => {...});
dotnet new maui -n MySuperApp
// Biometric Auth in .NET 10
var result = await BiometricAuthentication.AuthenticateAsync(
new AuthenticationRequest("Login", "Scan your fingerprint"));
if (result.Authenticated) LoadSecureData();
<BlazorWebView HostPage="wwwroot/index.html">
<BlazorWebView.RootComponents>
<RootComponent Selector="#app" ComponentType="{x:Type local:Main}" />
</BlazorWebView.RootComponents>
</BlazorWebView>
<CollectionView ItemsSource="{Binding Posts}"
CachingStrategy="RecycleElement"
ItemTemplate="{StaticResource PostTemplate}" />
if (DeviceInfo.Platform != DevicePlatform.Android || DeviceInfo.DeviceType == DeviceType.Virtual)
{
// Simplify animations
}
var animation = new Animation(v => myLabel.Rotation = v, 0, 360);
animation.Commit(this, "RotateAnimation", 16, 2000, Easing.Linear);
<BoxView
Color="Red"
WidthRequest="60"
HeightRequest="60"
CornerRadius="30"
HorizontalOptions="Start"
VerticalOptions="Start">
<BoxView.GestureRecognizers>
<PanGestureRecognizer PanUpdated="OnPanUpdated" />
</BoxView.GestureRecognizers>
private double _startX, _startY;
void OnPanUpdated(object sender, PanUpdatedEventArgs e)
{
var box = (BoxView)sender;
switch (e.StatusType)
{
case GestureStatus.Started:
_startX = box.TranslationX;