Image in XAML

2 posts, 0 answers
  1. GuruuMeditation
    GuruuMeditation avatar
    5 posts
    Member since:
    May 2010

    Posted 10 Sep Link to this post

     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

     

     

     

     

  2. Yana
    Admin
    Yana avatar
    4897 posts

    Posted 10 Sep Link to this post

    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
Back to Top