开发者

Dynamically bind a textblock in a looping selector in wp7

开发者 https://www.devze.com 2023-04-12 03:59 出处:网络
I am developing an application where I have a class called UIManager in which there is a method which has an array of data

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/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号