A
A
Abc Edc2016-05-02 08:12:39
Mobile development
Abc Edc, 2016-05-02 08:12:39

How to make a list in xaml?

<corelayouts:CarouselViewDots 
        BindingContext="{Binding Path=.}" 
        HorizontalOptions="FillAndExpand" 
        VerticalOptions="FillAndExpand"  
        DotColor="White" 
        DotSize="6" 
        ScrollToIndex="{Binding ScrollToIndex, Mode=TwoWay}">
      <corelayouts:CarouselViewDots.CarouselViews>
        <View> // Здесь предполагается список из вьюх для будущих слайдов
          <citem:NewsCarouselView/>
        </View>
      </corelayouts:CarouselViewDots.CarouselViews>
    </corelayouts:CarouselViewDots>

private IEnumerable<View> _carouselViews;


        public IEnumerable<View> CarouselViews
        {
            get { return _carouselViews; }
            set
            {
                _carouselViews = value;
            }
        }

Well, this is naturally not a working code, just for an example of what I want to get as a result

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wcoder, 2016-05-02
@gleber1

If you use the control from this article www.maiersoft.de/blog/creating-a-xamarin-forms-car...
Use ItemTemplatedefault property + ContentView control:

<corelayouts:CarouselViewDots.ItemTemplate>
  <DataTemplate>
    <ContentView Content="{Binding .}"/> // биндим View из коллекции
  </DataTemplate>
</corelayouts:CarouselViewDots.ItemTemplate>

Pay attention to the device controls, namely the default property ItemTemplate that works internally like this:
foreach (var item in ItemsSource) {
    var view = (View)ItemTemplate.CreateContent();
    var bindableObject = view as BindableObject;
    if (bindableObject != null)
        bindableObject.BindingContext = item;
    _stack.Children.Add (view);
}

_stack is a StackLayout control .
you can do what you want by creating your own BindableProperty (following the ItemsSource example) - a list of views, when changed, the contents of the StackLayout will change.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question