RadSideDrawer Error initialize

0 Answers 44 Views
SideDrawer
Ioannis
Top achievements
Rank 1
Iron
Ioannis asked on 09 Feb 2024, 08:53 AM

i have a radsidedrwaer and i get System.ArgumentNullException: 'Value cannot be null. (Parameter 'view')' get 

on app center i get 

ElementExtensions.ToHandler (IElement view, IMauiContext context) D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:58
ElementExtensions.ToPlatform (IElement view, IMauiContext context) D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:127
Telerik.Maui.RadSideDrawerExtensions.UpdateDrawerContent(RadSideDrawer nativeSideDrawer, IRadSideDrawer sideDrawer)
Telerik.Maui.Handlers.RadSideDrawerHandler.MapDrawerContent(RadSideDrawerHandler handler, IRadSideDrawer virtualElement)
PublicKeyToken=5803cfa389c90ce7]].<Add>b__0 (IElementHandler h, IElement v) D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:172
PropertyMapper.UpdatePropertyCore (String key, IElementHandler viewHandler, IElement virtualView) D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:47
PropertyMapper.UpdateProperties (IElementHandler viewHandler, IElement virtualView) D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:82
ElementHandler.SetVirtualView (IElement view) D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:79
PublicKeyToken=5803cfa389c90ce7]].SetVirtualView (IView view) D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:53
PublicKeyToken=5803cfa389c90ce7]].SetVirtualView (IElement view) D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:56
Element.SetHandler (IElementHandler newHandler) D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:921
Element.set_Handler (IElementHandler value) D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:863
IElement.set_Handler (IElementHandler value) D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:2031
ElementExtensions.ToHandler (IElement view, IMauiContext context) D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:96
ElementExtensions.ToPlatform (IElement view, IMauiContext context) D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:127
LayoutHandler.SetVirtualView (IView view) D:\a\_work\1\s\src\Core\src\Handlers\Layout\LayoutHandler.Android.cs:41
PublicKeyToken=null]].SetVirtualView (IElement view) D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:56
Element.SetHandler (IElementHandler newHandler) D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:921
Element.set_Handler (IElementHandler value) D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:863
IElement.set_Handler (IElementHandler value) D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:2031
ElementExtensions.ToHandler (IElement view, IMauiContext context) D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:96
ElementExtensions.ToPlatform (IElement view, IMauiContext context) D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:127
ContentViewHandler.UpdateContent (IContentViewHandler handler) D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:42
ContentViewHandler.MapContent (IContentViewHandler handler, IContentView page) D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:47
PublicKeyToken=null]].<Add>b__0 (IElementHandler h, IElement v) D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:172
PropertyMapper.UpdatePropertyCore (String key, IElementHandler viewHandler, IElement virtualView) D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:47
PropertyMapper.UpdateProperties (IElementHandler viewHandler, IElement virtualView) D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:82
ElementHandler.SetVirtualView (IElement view) D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:79
PublicKeyToken=null]].SetVirtualView (IView view) D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:53
ContentViewHandler.SetVirtualView (IView view) D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:26
PublicKeyToken=null]].SetVirtualView (IElement view) D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:56
Element.SetHandler (IElementHandler newHandler) D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:921
Element.set_Handler (IElementHandler value) D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:863
IElement.set_Handler (IElementHandler value) D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:2031
ElementExtensions.ToHandler (IElement view, IMauiContext context) D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:96
ElementExtensions.ToPlatform (IElement view, IMauiContext context) D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:127
MauiContextExtensions.ToPlatform (IView view, IMauiContext fragmentMauiContext, Context context, LayoutInflater layoutInflater, FragmentManager childFragmentManager) D:\a\_work\1\s\src\Core\src\Platform\Android\MauiContextExtensions.cs:96
NavigationViewFragment.OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) D:\a\_work\1\s\src\Core\src\Platform\Android\Navigation\NavigationViewFragment.cs:56
Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) C:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release\net6.0-android\generated\src\AndroidX.Fragment.App.Fragment.cs:2031
JNINativeWrapper.Wrap_JniMarshal_PPLLL_L (_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:367 

The sidedrawer:

<Grid>
        <telerik:RadSideDrawer x:Name="drawer" DrawerLength="250">
            <telerik:RadSideDrawer.MainContent>
                <tools:KeyboardView>
                    <AbsoluteLayout x:Name="mainLayout">
                        <StackLayout x:Name="mainStackLayout" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" Spacing="0">
                            <StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand" HeightRequest="50">
                                <Grid Style="{StaticResource BottomGrid}" >
                                    <Grid.RowDefinitions>
                                         <RowDefinition Height="50"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="70*" />
                                        <ColumnDefinition Width="15*" />
                                        <ColumnDefinition Width="15*" />
                                    </Grid.ColumnDefinitions>
                                    <StackLayout Grid.Row="0" Grid.Column="0" Margin="-10, 0, 0, 0">
                                        <SearchBar x:Name="SearchBox" TextChanged="SearchBox_TextChanged" SearchButtonPressed="SearchBox_SearchButtonPressed" Style="{StaticResource SearchBar}" />
                                    </StackLayout>
                                    <StackLayout Grid.Row="0" Grid.Column="1">
                                        <Button x:Name="BtnTopologies" Grid.Row="0" Grid.Column="1" Style="{StaticResource Icon}" ImageSource="TreeView.png" Clicked="BtnTopologies_Clicked"/>
                                    </StackLayout>
                                    <StackLayout Grid.Row="0" Grid.Column="2">
                                        <Image Source="barcodeBtn.png">
                                            <Image.GestureRecognizers>
                                                <TapGestureRecognizer Tapped="BtnBarcode_Clicked" NumberOfTapsRequired="1" />
                                            </Image.GestureRecognizers>
                                        </Image>
                                    </StackLayout>
                                </Grid>
                            </StackLayout>
                            <StackLayout Orientation="Horizontal">
                                <telerik:RadComboBox x:Name="sortByField" IsClearButtonVisible="False" SelectionChanged="sortByField_SelectionChanged" VerticalOptions="Center" WidthRequest="150" TextColor="{StaticResource LightBlueColor}"/>
                                <Image x:Name="sortingImg" Source="arrow.png">
                                    <Image.GestureRecognizers>
                                        <TapGestureRecognizer Tapped="OrderTapped" NumberOfTapsRequired="1" />
                                    </Image.GestureRecognizers>
                                </Image>
                            </StackLayout>
                            <StackLayout x:Name="listViewDynamic">
 
                            </StackLayout>
                            <telerik:RadListView x:Name="AssetsList" 
                                                             Grid.Row="1"
                                                             SelectionMode="Single" 
                                                             SelectionGesture="Tap"            
                                                             SwipeOffset="50, 0, 50, 0" 
                                                             SwipeThreshold="10"
                                                             HeightRequest="30"
                                                             SelectionChanged="AssetsList_ItemTapped"
                                                             RefreshRequested="AssetsList_RefreshRequested"
                                                             IsPullToRefreshActive="True"
                                                             IsPullToRefreshEnabled="True"
                                                             VerticalOptions="FillAndExpand"
                                                             BackgroundColor="LightGray" >
                                <telerik:RadListView.ItemStyle>
                                    <telerik:ListViewItemStyle BackgroundColor="Transparent"
                                           BorderColor="Transparent"
                                           BorderLocation="None"
                                           BorderWidth="0"/>
                                </telerik:RadListView.ItemStyle>
                                <telerik:RadListView.ItemTemplate >
                                    <DataTemplate>
                                        <telerik:ListViewTemplateCell >
                                            <telerik:ListViewTemplateCell.View>
                                                <telerik:RadBorder BorderColor="#268ecd" Margin="3,6" BorderThickness="0" CornerRadius="18" >
                                                    <StackLayout Orientation="Horizontal" 
                                                                 Style="{StaticResource ListItem}" 
                                                                 VerticalOptions="Start" 
                                                                 Padding="0" 
                                                                 BackgroundColor="White">                                                        
                                                        <StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" Spacing="0" Padding="10, 15, 0, 15">
                                                            <StackLayout Orientation="Vertical" HorizontalOptions="StartAndExpand" Spacing="5">
                                                                <Label Text="{Binding Code}" Style="{StaticResource ListHeader}" TextColor="{StaticResource BlueColor}" />
                                                                <Label Text="{Binding Description}" Style="{StaticResource ListInfo}" TextColor="{StaticResource LightBlueColor}" />
                                                                <Label MaxLines="2" LineBreakMode="TailTruncation" Text="{Binding FullPath}" Style="{StaticResource ListInfo}" TextColor="{StaticResource LightGreyColor}" />
                                                            </StackLayout>
                                                        </StackLayout>
                                                    </StackLayout>
                                                </telerik:RadBorder>
                                            </telerik:ListViewTemplateCell.View>
                                        </telerik:ListViewTemplateCell>
                                    </DataTemplate>
                                </telerik:RadListView.ItemTemplate>
                            </telerik:RadListView>
                        </StackLayout>
                    </AbsoluteLayout>
                </tools:KeyboardView>
            </telerik:RadSideDrawer.MainContent>
        </telerik:RadSideDrawer>
    </Grid>

 

Yana
Telerik team
commented on 13 Feb 2024, 12:02 PM

Hi Ioannis,

Thank you for sharing the code, it was of much help.

The reason for the exception is the fact the SideDrawer does not have DrawerContent - in general,  SideDrawer control consists of MainContent and DrawerContent as the drawer is initially hidden. 

Do you at some point ( later or in code-behind) add a DrawerContent in the concrete scenario? I am asking as I'd like to log this as a bug report and I'd need to understand the exact use case you have.

Looking forward to your reply.

No answers yet. Maybe you can help?

Tags
SideDrawer
Asked by
Ioannis
Top achievements
Rank 1
Iron
Share this question
or