This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class MainPage : ContentPage | |
{ | |
private MainPageViewModel ViewModel => BindingContext as MainPageViewModel; | |
public MainPage(MainPageViewModel viewModel) | |
{ | |
InitializeComponent(); | |
BindingContext = viewModel; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Option 1 | |
foreach (var viewModel in assembly.DefinedTypes.Where(e => e.IsSubclassOf(typeof(ViewModel)))) | |
{ | |
builder.Services.AddTransient(viewModel.GetType()); | |
} | |
foreach (var view in assembly.DefinedTypes.Where(e => e.IsSubclassOf(typeof(Views.View)))) | |
{ | |
builder.Services.AddTransient(view.GetType()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyViewModel : ViewModelBase | |
{ | |
public event EventHandler DataUpdated | |
public override Task Initialize() | |
{ | |
//Subscribe to event when ViewModel in initialized. | |
DataUpdated += Data_DataUpdated; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mvvm:TinyApplication xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
xmlns:windows="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;assembly=Microsoft.Maui.Controls" | |
xmlns:local="clr-namespace:MauiSample" | |
xmlns:mvvm="clr-namespace:TinyMvvm.Maui;assembly=TinyMvvm.Maui" | |
x:Class="MauiSample.App" | |
windows:Application.ImageDirectory="Assets"> | |
<Application.Resources> | |
<ResourceDictionary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<CarouselView ItemSource="{Binding Persons, Mode=OneTime}"> | |
<CarouselView.ItemTemplate> | |
<DataTemplate x:DataType="models:Person"> | |
<Grid RowDefinitions="*, 30"> | |
<Image Source="{Binding Photo, Mode=OneTime}" /> | |
<Label Grid.Row="1" Text="{Binding Name Mode=OneTime}" /> | |
</Grid> | |
</DataTemplate> | |
</CarouselView.ItemTemplate> | |
</CarouselView> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Person> {get; set;} = new List<Person>() | |
{ | |
new Person() {Name = "Daniel Hindrikes", Photo="daniel.png"}, | |
new Person() {Name = "Satya Nadella", Photo="satya.png"} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Button Text="Create" Command="{Binding Create, Mode=OneTime}" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ICommand Create => new TinyCommand(async() => { | |
await CreatePerson(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<CollectionView ItemSource="{Binding Items}"> | |
<CollectionView.ItemTemplate> | |
<DataTemplate x:DataType="models:Person"> | |
<StackLayout> | |
<Label Text="{Binding Name, Mode=OneTime}" /> | |
<Label Text="{Binding Email, Mode=OneTime}" /> | |
<label Text="{Binding Count}" /> | |
</DataTemplate> | |
</CollectionView.ItemTemplate> | |
</CollectionView> |
NewerOlder