This is a migrated thread and some comments may be shown as answers.

Image in XAML

1 Answer 27 Views
SegmentedControl
This is a migrated thread and some comments may be shown as answers.
GuruuMeditation
Top achievements
Rank 1
GuruuMeditation asked on 10 Sep 2019, 09:29 AM

 Hi,

 

Is there an example out there of the segmented control with images, but in XAML ? I don't want to make a binding just for that.

 

Thanks

 

Regards

 

Olivier

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 10 Sep 2019, 01:10 PM

Hi Olivier,

In general, you could define a collection of Image file as ItemsSource of the SegmentedControl in XAML in a similar way as a collection of strings.  Here is a quick snippet showing the exact approach:

<telerikInput:RadSegmentedControl x:Name="segmentControl"
                            Margin="10"
                            DisabledSegmentTextColor="#C2C3C9"
                            HeightRequest="60"
                            SegmentBackgroundColor="#FFFFFF"
                            SegmentTextColor="#3A9BFD"
                            SelectedSegmentBackgroundColor="#3A9BFD"
                            SelectedSegmentTextColor="#FFFFFF"
                            VerticalOptions="Start">
    <telerikInput:RadSegmentedControl.ItemsSource>
        <x:Array Type="{x:Type FileImageSource}">
            <FileImageSource File="Segmented_Dinner.png" />
            <FileImageSource File="Segmented_Drinks.png" />
            <FileImageSource File="Segmented_Snacks.png" />
        </x:Array>
    </telerikInput:RadSegmentedControl.ItemsSource>
</telerikInput:RadSegmentedControl>

In the example above a FileImageSource is used, which means that the images are taken from the platform-specific projects.  For more details on this check the Images in Xamarin.Forms topic in the Xamarin documentation.

I've attached a sample app showing the approach for a reference.

I hope I was of help. Let me know if any additional questions pop up.

Regards,
Yana
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
SegmentedControl
Asked by
GuruuMeditation
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or