Telerik Forums
UI for .NET MAUI Forum
0 answers
13 views

Example: Nothing selected

Selecting The Child: Parent not selected. ( results in parent selected )

Selecting the Child:Parent Selected (results in child selected)

Can the selected item in the tree go directly to the item clicked instead of selecting the parent first?

Sean
Top achievements
Rank 2
Iron
 asked on 26 Apr 2024
1 answer
34 views
For Desktop application: we neen to build customized toolbar - that might contained some sub toolbar items. Can we use In telerik:ListPickerButtonToolbarItem?
Didi
Telerik team
 answered on 18 Oct 2023
3 answers
281 views
After adding items to the tree, I want to check an initial set of items and it is not working.  I have tried using "CheckedItems.Add()" and also setting the CheckedItems property to a list of objects.  Neither seems to work.  Am I doing something wrong?
Paul
Top achievements
Rank 1
Iron
 answered on 11 Oct 2023
1 answer
192 views

RadTreeView during rendering. I tried to comment out all of the Templete overrides in the resource dictionary AND I've also removed the <fluent:MauiIcon> in the ItemTemplate.

Unable to cast object of type 'Telerik.Maui.Handlers.RadButtonHandler' to type 'Microsoft.Maui.Platform.IImageSourcePartSetter'.

 

   at Microsoft.Maui.Platform.ImageSourcePartLoader..ctor(IElementHandler handler, Func`1 imageSourcePart, Action`1 setImage)
   at Telerik.Maui.Handlers.RadButtonHandler..ctor(IPropertyMapper mapper)
   at Telerik.Maui.Handlers.RadButtonHandler..ctor()
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)

   at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType, ServiceDescriptor single, IEnumerable`1 enumerable)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Telerik.Maui.RadBorderExtensions.UpdateBorderContent(Border nativeBorder, IRadBorder border)
   at Telerik.Maui.Handlers.RadBorderHandler.MapContent(RadBorderHandler handler, IRadBorder border)
   at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler)
   at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page)
   at Microsoft.Maui.Controls.TemplatedView.OnApplyTemplateImpl()
   at Microsoft.Maui.Controls.TemplatedView.OnApplyTemplate()
   at Microsoft.Maui.Controls.TemplatedView.Microsoft.Maui.Controls.IControlTemplated.OnApplyTemplate()
   at Microsoft.Maui.Controls.TemplateUtilities.OnControlTemplateChanged(BindableObject bindable, Object oldValue, Object newValue)
   at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent)
   at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value)
   at Telerik.Maui.Controls.RadCompositeContentView.set_ActualControlTemplate(ControlTemplate value)
   at Telerik.Maui.Controls.RadCompositeContentView.UpdateActualControlTemplate(ControlTemplate customTemplate)
   at Telerik.Maui.Controls.RadCompositeContentView.UpdateActualControlTemplate()
   at Telerik.Maui.Controls.RadCompositeContentView.InitializeComponent()
   at Telerik.Maui.Controls.RadCompositeContentView.OnHandlerChanged()
   at Telerik.Maui.Controls.ItemsView.ItemView.OnHandlerChanged()
   at Microsoft.Maui.Controls.VisualElement.OnHandlerChangedCore()
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.Add(IView child)
   at Microsoft.Maui.Handlers.LayoutHandler.MapAdd(ILayoutHandler handler, ILayout layout, Object arg)
   at Microsoft.Maui.CommandMapper.InvokeCore(String key, IElementHandler viewHandler, IElement virtualView, Object args)
   at Microsoft.Maui.Handlers.ElementHandler.Invoke(String command, Object args)
   at Microsoft.Maui.Controls.Layout.NotifyHandler(String action, Int32 index, IView view)
   at Microsoft.Maui.Controls.Layout.OnAdd(Int32 index, IView view)
   at Microsoft.Maui.Controls.Layout.Add(IView child)
   at Telerik.Maui.Controls.RadItemsView.CreateItemView()
   at Telerik.Maui.Controls.RadItemsView.Telerik.Maui.Controls.ItemsView.IRadItemsView.CreateItemView()
   at Telerik.Maui.Controls.ItemsView.ItemViewProvider.CreateItemView(Object dataItem)
   at Telerik.Maui.Controls.ItemsView.ItemViewProvider.GetItemView(Object dataItem)
   at Telerik.Maui.Controls.ItemsView.ItemsViewVerticalLayoutStrategy.GetItemView(Object dataItem)
   at Telerik.Maui.Controls.ItemsView.ItemsViewVerticalLayoutStrategy.GetItemView(Int32 itemIndex)
   at Telerik.Maui.Controls.ItemsView.ItemsViewVerticalLayoutStrategy.ExpandEnd(Size availableSize)
   at Telerik.Maui.Controls.ItemsView.ItemsViewVerticalLayoutStrategy.ArrangeChildren(Rect layoutBounds)
   at Telerik.Maui.Controls.ItemsView.ItemsVirtualLayout.ArrangeChildren(Rect layoutBounds)
   at Microsoft.Maui.Platform.LayoutPanel.ArrangeOverride(Size finalSize)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
   at Microsoft.Maui.ViewHandlerExtensions.PlatformArrangeHandler(IViewHandler viewHandler, Rect rect)
   at Microsoft.Maui.Controls.VisualElement.ArrangeOverride(Rect bounds)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IView.Arrange(Rect bounds)
   at Telerik.Maui.Controls.ItemsView.ItemsScrollLayout.ArrangeChildren(Rect layoutBounds)
   at Microsoft.Maui.Platform.LayoutPanel.ArrangeOverride(Size finalSize)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
   at Microsoft.Maui.ViewHandlerExtensions.PlatformArrangeHandler(IViewHandler viewHandler, Rect rect)
   at Microsoft.Maui.Controls.VisualElement.ArrangeOverride(Rect bounds)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IView.Arrange(Rect bounds)
   at Microsoft.Maui.Layouts.GridLayoutManager.ArrangeChildren(Rect bounds)
   at Microsoft.Maui.Platform.LayoutPanel.ArrangeOverride(Size finalSize)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
   at Microsoft.Maui.ViewHandlerExtensions.PlatformArrangeHandler(IViewHandler viewHandler, Rect rect)
   at Microsoft.Maui.Controls.VisualElement.ArrangeOverride(Rect bounds)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IView.Arrange(Rect bounds)
   at Microsoft.Maui.Controls.Compatibility.Layout.LayoutChildIntoBoundingRegion(VisualElement child, Rect region)
   at Microsoft.Maui.Controls.TemplatedView.LayoutChildren(Double x, Double y, Double width, Double height)
   at Microsoft.Maui.Controls.Compatibility.Layout.UpdateChildrenLayout()
   at Microsoft.Maui.Controls.VisualElement.UpdateBoundsComponents(Rect bounds)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IView.Arrange(Rect bounds)
   at Microsoft.Maui.Controls.Compatibility.Layout.LayoutChildIntoBoundingRegion(VisualElement child, Rect region)
   at Microsoft.Maui.Controls.TemplatedView.LayoutChildren(Double x, Double y, Double width, Double height)
   at Microsoft.Maui.Controls.Compatibility.Layout.UpdateChildrenLayout()
   at Microsoft.Maui.Controls.VisualElement.UpdateBoundsComponents(Rect bounds)
   at Microsoft.Maui.Controls.VisualElement.set_Frame(Rect value)
   at Microsoft.Maui.Controls.TemplatedView.ArrangeOverride(Rect bounds)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IView.Arrange(Rect bounds)
   at Microsoft.Maui.Layouts.GridLayoutManager.ArrangeChildren(Rect bounds)
   at Microsoft.Maui.Platform.LayoutPanel.ArrangeOverride(Size finalSize)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
   at Microsoft.Maui.ViewHandlerExtensions.PlatformArrangeHandler(IViewHandler viewHandler, Rect rect)
   at Microsoft.Maui.Controls.VisualElement.ArrangeOverride(Rect bounds)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IView.Arrange(Rect bounds)
   at Microsoft.Maui.Controls.Compatibility.Layout.LayoutChildIntoBoundingRegion(VisualElement child, Rect region)
   at Microsoft.Maui.Controls.Page.LayoutChildren(Double x, Double y, Double width, Double height)
   at Microsoft.Maui.Controls.Page.UpdateChildrenLayout()
   at Microsoft.Maui.Controls.Page.OnSizeAllocated(Double width, Double height)
   at Microsoft.Maui.Controls.VisualElement.UpdateBoundsComponents(Rect bounds)
   at Microsoft.Maui.Controls.VisualElement.set_Frame(Rect value)
   at Microsoft.Maui.Controls.ContentPage.Microsoft.Maui.ICrossPlatformLayout.CrossPlatformArrange(Rect bounds)
   at Microsoft.Maui.Platform.ContentPanel.ArrangeOverride(Size finalSize)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.ArrangeOverride(IObjectReference _obj, Size finalSize)
   at Microsoft.UI.Xaml.FrameworkElement.ArrangeOverride(Size finalSize)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.ArrangeOverride(IObjectReference _obj, Size finalSize)
   at Microsoft.UI.Xaml.FrameworkElement.ArrangeOverride(Size finalSize)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
   at Microsoft.UI.Xaml.UIElement.Arrange(Rect finalRect)
   at Microsoft.Maui.Platform.WindowRootViewContainer.ArrangeOverride(Size finalSize)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)

 

 

Xaml:

        <telerik:RadTreeView
            x:Name="treeview"
            Grid.Row="2"
            AutomationId="treeview"
            CheckBoxMode="None"
            ItemStyle="{StaticResource Key=TreeViewStyle1}"
            ItemsSource="{Binding SqlPlan.SparkPlanInfos}"
            LevelIndentation="10">
            <telerik:TreeViewDescriptor ItemsSourcePath="Children" TargetType="{x:Type models:SparkPlanInfo}" />
            <telerik:RadTreeView.ItemTemplate>
                <DataTemplate x:DataType="models:SparkPlanInfo">
                    <Grid ColumnDefinitions="auto,auto,*,auto">
                        <fluent:MauiIcon
                            Margin="-15,5,10,0"
                            Icon="{Binding NodeName, Converter={StaticResource SparkOperationToIconKey}, ConverterParameter='16', FallbackValue={x:Static fluent:FluentIcons.Accessibility16}}"
                            IconColor="Black"
                            IconSize="16" />
                        <Label
                            Grid.Column="1"
                            LineBreakMode="WordWrap"
                            Text="{Binding NodeName}"
                            VerticalOptions="Center" />
                        <Label
                            Grid.Column="2"
                            Margin="20,0"
                            HorizontalOptions="Start"
                            HorizontalTextAlignment="Start"
                            IsVisible="{Binding IsSimpleStringUnequalToNodeName}"
                            LineBreakMode="NoWrap"
                            MaximumWidthRequest="600"
                            Text="{Binding SimpleStringWithoutStartingNodeName}"
                            ToolTipProperties.Text="{Binding SimpleString}"
                            VerticalOptions="Center" />

                    </Grid>
                </DataTemplate>
            </telerik:RadTreeView.ItemTemplate>
        </telerik:RadTreeView>

 

 

    <ContentPage.Resources>
        <ResourceDictionary>
            <converters:SparkOperationToIconConverter x:Key="SparkOperationToIconKey" />

            <ControlTemplate x:Key="TreeViewTemplate1">
                <telerik:RadBorder
                    Padding="{TemplateBinding ContentPadding}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderColor="{TemplateBinding BorderColor}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    CornerRadius="{TemplateBinding CornerRadius}">
                    <telerik:TreeViewItemLayout Indentation="{TemplateBinding Indentation}" Spacing="{TemplateBinding Spacing}">

                        <telerik:TreeViewItemExpandButton
                            Command="{TemplateBinding ToggleExpandedCommand}"
                            IsEnabled="{TemplateBinding IsEnabled}"
                            IsExpanded="{TemplateBinding IsExpanded}"
                            IsLeaf="{TemplateBinding IsLeaf}"
                            IsVisible="{TemplateBinding IsExpandButtonVisible}"
                            Style="{TemplateBinding ExpandButtonStyle}"
                            TextColor="{TemplateBinding TextColor}" />

                        <telerik:TreeViewItemCheckBox
                            IsChecked="{TemplateBinding IsChecked}"
                            IsEnabled="{TemplateBinding IsEnabled}"
                            IsVisible="{TemplateBinding IsCheckBoxVisible}"
                            Style="{TemplateBinding CheckBoxStyle}" />

                        <telerik:TreeViewItemImage
                            IsEnabled="{TemplateBinding IsEnabled}"
                            IsVisible="{TemplateBinding IsImageVisible}"
                            Source="{TemplateBinding ImageSource}"
                            Style="{TemplateBinding ImageStyle}" />

                        <!--  content presenter for presenting the (ItemTemplate/Text if itemtemplate is not used)  -->
                        <ContentPresenter />
                    </telerik:TreeViewItemLayout>
                </telerik:RadBorder>
            </ControlTemplate>

            <Style x:Key="TreeViewStyle1" TargetType="telerik:TreeViewItemView">
                <!--  control template can be defined through style  -->
                <Setter Property="ControlTemplate" Value="{StaticResource TreeViewTemplate1}" />
                <Setter Property="IsImageVisible" Value="True" />
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>
Didi
Telerik team
 answered on 14 Sep 2023
3 answers
64 views
Does the Maui TreeView control will have a method CheckItem(object item) like in xamarin TreeView?
Didi
Telerik team
 answered on 13 Sep 2023
1 answer
40 views

Hello there!

I would like to know how I can expand/collapse a single node in the treeview by code. Can anybody help me?
And also if there is a chance to get notified in case of expanse/collapse (OnExpand event)

thanks a lot

regards

Sven

Lance | Senior Manager Technical Support
Telerik team
 answered on 21 Jul 2023
1 answer
68 views

  <telerik:RadDataGrid x:Name="dataGrid"
                         ItemsSource="{Binding People}">
        <telerik:RadDataGrid.GroupHeaderTemplate>

              <telerik:RadTreeView x:Name="treeView" 
                         ItemsSource="{Binding Items}" 
                         CheckBoxMode="Recursive">
        <telerik:TreeViewDescriptor DisplayMemberPath="Name"
                                    ItemsSourcePath="Children"
                                    TargetType="{x:Type local:Item}" />
        <telerik:RadTreeView.BindingContext>
            <local:ViewModel/>
        </telerik:RadTreeView.BindingContext>
    </telerik:RadTreeView>


        </telerik:RadDataGrid.GroupHeaderTemplate>        
    </telerik:RadDataGrid>

 

 

 public class Item
    {
        public Item(string name)
        {
            this.Name = name;
            this.Children = new ObservableCollection<Item>();
        }

        public string Name { get; set; }
        public IList<Item> Children { get; set; }
    }        

 

 

 

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
    public Gender Gender { get; set; }
}
Lance | Senior Manager Technical Support
Telerik team
 answered on 10 Jul 2023
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?