Telerik Forums
UI for Xamarin Forum
1 answer
261 views

I'm trying to create a custom expand / collapse indicator for my tree items but there is one situation where it is not working: when the item has no children the indicator is wrong. I'm using the technique suggested in this forum post to fill my tree on demand.

I have tried two different approaches but neither one gives an accurate result.

1. Binding to IsExpanded:

I have created a value converter:

public class TreeIconConverter : IValueConverter
{
    public string ExpandIcon { get; set; }
    public string CollapseIcon { get; set; }
    public string LeafIcon { get; set; }
 
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is bool expanded)
            return expanded ? CollapseIcon : ExpandIcon;
        return null;
    }
 
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

and I'm using a Label as the custom tree indicator:

<Label HeightRequest="24" WidthRequest="24" HorizontalOptions="Center" VerticalOptions="Center"
    FontFamily="{StaticResource IconFont}" FontSize="{StaticResource SelectionIconSize}"
    Text="{Binding IsExpanded, Converter={StaticResource TreeIconConverter}}"/>

 

This gives the best result, but when the item has no children the ExpandIcon is shown. 

2. Binding to TreeViewDataItem:

I have altered the value converter to try and detect when the item has children:

public class TreeIconConverter : IValueConverter
{
    public string ExpandIcon { get; set; }
    public string CollapseIcon { get; set; }
    public string LeafIcon { get; set; }
 
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is TreeViewDataItem item)
        {
            if (!item.IsExpanded)
                return CollapseIcon;
 
            if (item.Item is LocationGroup group)
            {
                if (group.HaveChildren && group.Children.Count == 0)
                    return LeafIcon;
            }
 
            return ExpandIcon;
        }
 
        return null;
    }
 
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

group.HaveChildren is true only after getting the group's children, if it's false we don't yet have the group's children in memory.

The Label has been changed to:

<Label HeightRequest="24" WidthRequest="24" HorizontalOptions="Center" VerticalOptions="Center"
    FontFamily="{StaticResource IconFont}" FontSize="{StaticResource SelectionIconSize}"
    Text="{Binding ., Converter={StaticResource TreeIconConverter}}"/>

With this second version, all the items always show the CollapseIcon.

 

 

 

 

Shawn
Top achievements
Rank 1
 answered on 26 Jun 2018
6 answers
322 views
How does one change the font family used by the calendar?
Ian
Top achievements
Rank 1
 answered on 25 Jun 2018
1 answer
94 views
What would be the best way to make an item visible? Something similar to the ListView's ScrollItemIntoView method?
Lance | Senior Manager Technical Support
Telerik team
 answered on 22 Jun 2018
2 answers
115 views

Does the TreeView support any kind of on demand update?

 

In other words: does it require the entire tree to be available on load, or can a node's children be made available only when expanding the node?

 

 

Cleanwatts
Top achievements
Rank 1
 answered on 22 Jun 2018
3 answers
59 views
When I have a calendar in a page it works in the app, but the preview in Visual Studio Mac crashes. Is there a fix for this?
Didi
Telerik team
 answered on 20 Jun 2018
1 answer
135 views

I have installed Xamarin UI and it give an error upon compilation...

/iOS/MTOUCH: Error MT2101: Can't resolve the reference 'System.Void ObjCRuntime.BlockLiteral::SetupBlockUnsafe(System.Delegate,System.Delegate)', referenced from the method 'System.Void TelerikUI.TKListView::PerformBatchUpdates(System.Action,System.Action`1<System.Boolean>)' in 'Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'. (MT2101) (iOS)

How do I fix this?

Ian
Top achievements
Rank 1
 answered on 16 Jun 2018
1 answer
226 views

Hi,

I'm using XamarinForms and have a telerik listview and an entry on a page and am using the entry to filter the listview. I have the filter wired up to my ViewModel and it is working without issue. However, I now notice that the multiple section that is enabled does not persist after the filter is applied. And since the SelectedItems property cannot be bound in MVVM, I cannot easily re-apply those selected items. Is there a property/workaround that will allow that persistence?

Lance | Senior Manager Technical Support
Telerik team
 answered on 15 Jun 2018
1 answer
178 views

I am trying to add an image to a button but I am having difficulty trying to align the image with the text.

I want some text with an image next to it - how can I align the image on a button?

Lance | Senior Manager Technical Support
Telerik team
 answered on 15 Jun 2018
5 answers
1.5K+ views

Segmented control doesn't seem to support multi line text (separated by newline character).

Is there a way we can make this work? Is this something that can be added via a custom renderer for both ios and android?

Lance | Senior Manager Technical Support
Telerik team
 answered on 14 Jun 2018
1 answer
281 views

Can the RadTabView have dynamically bound items using a ItemTemplate (like a ListView)? 

If not, are there any workarounds?

Lance | Senior Manager Technical Support
Telerik team
 answered on 13 Jun 2018
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?