I have this chunk of code
<sfPopup:SfPopup
x:Name="UserProfilePopup"
AbsoluteY="20"
AcceptButtonText="Save and close"
AcceptCommand="{Binding SavePopUpContentCommand}"
HeaderHeight="90"
HeightRequest="400"
RelativePosition="AlignTopRight"
RelativeView="{x:Reference UserProfileImage}"
ShowFooter="True"
ShowHeader="True"
ShowOverlayAlways="False"
WidthRequest="400">
<sfPopup:SfPopup.HeaderTemplate>
<DataTemplate x:DataType="model:LocalUser">
<toolkit:AvatarView
Margin="20,10,0,0"
BorderColor="Black"
BorderWidth="1"
CornerRadius="80"
FontFamily="MaterialSymbol"
FontSize="20"
HeightRequest="80"
HorizontalOptions="Start"
ImageSource="{Binding ImagePath}"
Text="{Static icons:MateriallFontGlyphs.Add_a_photo}"
TextColor="Black"
WidthRequest="80">
<toolkit:AvatarView.GestureRecognizers>
<PointerGestureRecognizer
x:Name="AvatarImage"
x:DataType="vm:AppShellViewModel"
PointerEntered="AvatarImage_PointerEntered"
PointerExited="AvatarImage_PointerExited" />
</toolkit:AvatarView.GestureRecognizers>
<toolkit:AvatarView.Behaviors>
<toolkit:EventToCommandBehavior
x:DataType="vm:AppShellViewModel"
Command="{Binding AvatarImageClickedCommand}" />
</toolkit:AvatarView.Behaviors>
</toolkit:AvatarView>
</DataTemplate>
</sfPopup:SfPopup.HeaderTemplate>
<sfPopup:SfPopup.PopupStyle>
<sfPopup:PopupStyle CornerRadius="0" />
</sfPopup:SfPopup.PopupStyle>
<sfPopup:SfPopup.ContentTemplate>
<DataTemplate x:DataType="model:LocalUser">
<Grid
Padding="20"
HorizontalOptions="Center"
RowDefinitions="80,80"
RowSpacing="5"
VerticalOptions="Center">
<controls:MaterialEntry
Hint="Name"
HintColor="Black"
HorizontalOptions="Start"
ShowIcon="False"
Text="{Binding Username}"
TextColor="Black" />
<controls:MaterialEntry
Grid.Row="1"
Hint="Status"
HintColor="Black"
HorizontalOptions="Start"
ShowIcon="False"
Text="{Binding StatusMessage}"
TextColor="Black" />
</Grid>
</DataTemplate>
</sfPopup:SfPopup.ContentTemplate>
I made my viewModel
namespace FireChat.ViewModels;
public partial class AppShellViewModel : BaseViewModel {
readonly FirebaseAuthClient _authClient;
readonly WeakReferenceMessenger _messenger;
readonly IMediaPicker _mediaPicker;
[ObservableProperty]
LocalUser localUser = new();
[ObservableProperty]
string? _userName;
public AppShellViewModel(FirebaseAuthClient authClient, WeakReferenceMessenger messenger, IMediaPicker mediaPicker) {
_authClient = authClient;
if(_authClient.User != null) {
_userName = _authClient.User.Info.DisplayName;
}
_messenger = messenger;
_mediaPicker = mediaPicker;
}
[RelayCommand]
async Task SignOut() {
_authClient.SignOut();
await Shell.Current.GoToAsync("..");
}
[RelayCommand]
void OpenProfile() {
_messenger.Send("OpenProfile");
}
[RelayCommand]
void SavePopUpContent() {
_messenger.Send("SavePopUpContent");
}
[RelayCommand]
async Task AvatarImageClicked() {
await Shell.Current.DisplayActionSheet("Choose an option", "Cancel", null, "Take a photo", "Choose from gallery");
var result = await _mediaPicker.PickPhotoAsync(new MediaPickerOptions {
Title = "Pick a photo"
});
if(result != null) {
var stream = await result.OpenReadAsync();
LocalUser.ImagePath = stream.ToString();
}
}
}
and it does not want to hit the command, to show me the propt
code
https://github.com/eduardoagr/MauiSamples