简体   繁体   中英

Dynamically bind a textblock in a looping selector in wp7

I am developing an application where I have a class called UIManager in which there is a method which has an array of data

public void DisplayCatalog(string[] displayName, BitmapImage[] icons)
    {
        DisplayItem.Clear();
        for (int i = 0; i < displayName.Length; i++)
        {
             DisplayItem.Add(new ItemList { WidgetName = displayName[i], Icon = icons[i] });
        }
        NotifyPropertyChanged("UI");
    }

Now I want this data ie;WidgetName to be displayed in my MainPage where I have used a Looping selector.

*<custom:LoopingSelector x:Name="selectorLeft" ItemMargin="5"  ItemSize="145,145" Margin="6,0,-6,22">
            <custom:LoopingSelector.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="{Binding WidgetName}"/>
                    </StackPanel>
                </DataTemplate>
            </custom:LoopingSelector.ItemTemplate>
        </custom:LoopingSelector>

* Also I need to scroll the looping selector Horizontally. How can I achieve this...??? Any valuable solutions Please....... I have used Horizontal Looping Selector but I am not getting how to bind the data from my UIManager class on to the Horizontal Looping Selector..

    <toolkit:HorizontalLoopingSelector Grid.Row="0" Margin="12" Height="128"        ItemSize="128,128" ItemTemplate="{StaticResource ?????}">
            <toolkit:HorizontalLoopingSelector.DataSource>
                ????????
                </toolkit:HorizontalLoopingSelector.DataSource>
             </toolkit:HorizontalLoopingSelector>

u need to create a datasource class and bind the values to the looping selector source .its similar to binding source to the vertical looping selector. Visit http://www.windowsphonegeek.com/articles/WP7-LoopingSelector-in-depth--Part1-Visual-structure-and-API

Check out this resource if you still require a horizontal loop selector:

http://blog.supaywasi.com/2011/06/horizontal-looping-selector/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM