Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@ async Task OnReturnButtonTapped(CancellationToken token)
{
await popupService.ClosePopupAsync<string>(navigation, ReturnText, token);
}

[ObservableProperty]
public partial string? SelectedTitle { get; set; }

[RelayCommand]
void OnTitleSelected()
{
if (SelectedTitle is not null)
{
ReturnText = SelectedTitle;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,51 @@
VerticalOptions="Center"
LineBreakMode="WordWrap" />

<CollectionView HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="250"
SelectionMode="Single"
SelectedItem="{Binding SelectedTitle}"
SelectionChangedCommand="{Binding TitleSelectedCommand}">
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Welcome, Program.</x:String>
<x:String>Initiating lightcycle…</x:String>
<x:String>End of line.</x:String>
</x:Array>
</CollectionView.ItemsSource>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<Border BackgroundColor="LightGray"
StrokeShape="RoundRectangle 8"
Padding="8"
Margin="4"
HorizontalOptions="Fill"
VerticalOptions="Center">

<VisualStateManager.VisualStateGroups>
<VisualStateGroup Name="CommonStates">
<VisualState Name="Normal" />
<VisualState Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="{StaticResource Blue100Accent}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>

<Label Text="{Binding .}"
TextColor="Black"
FontSize="16" HorizontalOptions="Center"/>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>

<Entry Placeholder="Enter text here then click Return"
HorizontalOptions="Center"
VerticalOptions="Center"
Text="{Binding ReturnText, Mode=OneWayToSource}"
Text="{Binding ReturnText, Mode=TwoWay}"
TextColor="{mct:AppThemeResource TextColor}"/>

<Button Text="Return"
Expand Down
11 changes: 5 additions & 6 deletions src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ public PopupPage(Popup popup, IPopupOptions? popupOptions)
await CloseAsync(new PopupResult(true));
}, () => GetCanBeDismissedByTappingOutsideOfPopup(popup, popupOptions));


var pageTapGestureRecognizer = new TapGestureRecognizer();
pageTapGestureRecognizer.Tapped += HandleTapGestureRecognizerTapped;
var pagePointerGestureRecognizer = new PointerGestureRecognizer();
pagePointerGestureRecognizer.PointerReleased += HandleTapGestureRecognizerTapped;

base.Content = new PopupPageLayout(popup, popupOptions)
{
GestureRecognizers = { pageTapGestureRecognizer }
GestureRecognizers = { pagePointerGestureRecognizer }
};

popup.PropertyChanged += HandlePopupPropertyChanged;
Expand Down Expand Up @@ -193,8 +192,8 @@ void IQueryAttributable.ApplyQueryAttributes(IDictionary<string, object> query)
popupContentIQueryAttributable.ApplyQueryAttributes(query);
}
}

void HandleTapGestureRecognizerTapped(object? sender, TappedEventArgs e)
void HandleTapGestureRecognizerTapped(object? sender, PointerEventArgs e)
{
ArgumentNullException.ThrowIfNull(sender);

Expand Down