I'm new at xamarin forms and developing an application. I make a popup page to make a menu. I'm using devexpress collectionview in it. My menu is grouped and I have 5 groups. I want collapse that groups but It doesn't work well.It works when page open first time but 2nd time it give me the error: "object reference not set to an instance of an object"
I check the dev express documentation for xamarin forms. There is nothing about grouping but in maui part I could find some information.
OnAppearing Method :
protected override void OnAppearing()
{
if (dxCollection.ItemCount >= 0)
{
dxCollection.CollapseGroup(-1);
dxCollection.CollapseGroup(-2);
dxCollection.CollapseGroup(-3);
dxCollection.CollapseGroup(-4);
dxCollection.CollapseGroup(-5);
}
base.OnAppearing();
}
Visual that I want.
Error : It appears page opened 2nd time. First time is working well. What could happen that lost object and give me error. I can not find.
What could I do for debuging ? I can not find anything to controll "null" here.
DxCollectionview Group:
<!--Group items.-->
<dxcv:DXCollectionView.GroupDescription >
<dxcv:GroupDescription FieldName="ANAGRUPADI" GroupInterval="Value"/>
</dxcv:DXCollectionView.GroupDescription>
<!--Define the group header template.-->
<dxcv:DXCollectionView.GroupHeaderTemplate >
<DataTemplate>
<StackLayout Margin="3" >
<Frame CornerRadius="8" Padding="0" Margin="0">
<StackLayout HeightRequest="30" HorizontalOptions="FillAndExpand" Orientation="Horizontal" BackgroundColor="CadetBlue" >
<Label FontFamily="Roboto" TextColor="Black" FontSize="Small" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" HorizontalOptions="CenterAndExpand" Text="{Binding Value}"/>
<Image Source="@drawable/popupmenu.png" HorizontalOptions="End" HeightRequest="20" />
</StackLayout>
</Frame>
</StackLayout>
</DataTemplate>
</dxcv:DXCollectionView.GroupHeaderTemplate>
LayoutChildren method :
protected override void LayoutChildren(double x, double y, double width, double height)
{
dxCollection.CollapseAllGroups();
base.LayoutChildren(x, y, width, height);
}
I want to add Xamarin.Kotlin.StdLib but it gives error. I cant find how to add those references. Error :
Version conflict detected for DevExpress.XamarinForms.Core. Install/reference DevExpress.XamarinForms.Core 22.1.8-pre-23026 directly to project İdaServis.Android to resolve this issue.
NU1202 Package Microsoft.Owin 4.2.2 is not compatible with monoandroid13.0 (MonoAndroid,Version=v13.0). Package Microsoft.Owin 4.2.2 supports: net45 (.NETFramework,Version=v4.5)
Firstly, I backup my project. I work on backup project.
My aim is adding Xamarin.Kotlin.StdLib because DevExpress Collectionview works great with this nuget package.
Then open android.csproj file with a text editor. I used VsCode. Add those lines :
<PackageReference Include="Xamarin.Google.Android.Material">
<Version>1.6.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Core">
<Version>1.7.0</Version>
</PackageReference>
After adding these I could add Xamarin.Kotlin.StdLib. But this was not enough. I fill my collectionview from my web service. Sometimes it doesn't collapse groups. Adding a delay time layoutchildren method make it great.
protected override async void LayoutChildren(double x, double y, double width, double height)
{
await Task.Delay(250);
dxCollection.CollapseAllGroups();
base.LayoutChildren(x, y, width, height);
}