I use Sharpnado CollectionView, I move from mainpage to tabbedpage, and from it I use contentpage, so in this case, only drag function works and drop does not. if I use just contentpage separately from tabbedpage everything works.
There's only one button on the mainpage, and it's clickable (maybe there's a problem here, but I can't find a good way to go to the tabbed page).
private async void ToBubleSort_Clicked(object sender, EventArgs e)
{
App.Current.MainPage = new TabbedPageBubleSort();
}
in tabbedpage
<TabbedPage
x:Class="AlgorithmsApp.ThemePages.BubleSort.TabbedPageBubleSort"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:AlgorithmsApp.ThemePages.BubleSort">
<local:TheoryPageBubleSort Title="Theory" />
<local:ExercisePageBubleSort Title="Exercise" />
</TabbedPage>
no need to show my exercisepage because its work in way without tabbedpage but i will show it just in case
<StackLayout Background="White" Orientation="Vertical">
<sho:CollectionView
x:Name="myCollection"
CollectionLayout="Vertical"
CollectionPadding="0,30,0,30"
EnableDragAndDrop="True"
ItemHeight="120">
<sho:CollectionView.ItemTemplate>
<DataTemplate>
<sho:DraggableViewCell x:Name="DraggableViewCell">
<StackLayout Margin="5" Orientation="Horizontal">
<Label
Padding="20"
FontSize="22"
Text="{Binding Text}"
TextColor="Green" />
</StackLayout>
</sho:DraggableViewCell>
</DataTemplate>
</sho:CollectionView.ItemTemplate>
</sho:CollectionView>
<Button
x:Name="check"
Padding="10"
BackgroundColor="AliceBlue"
Clicked="check_Clicked"
CornerRadius="25"
HeightRequest="100"
Text="Проверить"
VerticalOptions="EndAndExpand"
WidthRequest="250" />
<Frame BorderColor="White" HeightRequest="150" />
</StackLayout>
and exercisepage.cs
List<ExerciseItem> items = new List<ExerciseItem>
{
new ExerciseItem { Text = "Element 2", OrderId = 1},
new ExerciseItem { Text = "Element 1", OrderId = 0},
new ExerciseItem { Text = "Element 3", OrderId = 2 }
};
public ExercisePageBubleSort()
{
InitializeComponent();
myCollection.ItemsSource = items;
}
private void check_Clicked(object sender, EventArgs e)
{
int count = 0;
foreach (var exerc in items)
{
if (exerc.OrderId == items.IndexOf(exerc))
{
count++;
}
}
if (count == items.Count())
{
alertAboutSuccesful();
}
else alertAboutFail();
}