简体   繁体   English

在wp7中的循环选择器中动态绑定文本块

[英]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 我正在开发一个应用程序,其中有一个名为UIManager的类,其中有一个具有数据数组的方法

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. 现在, 我希望此数据(即WidgetName)显示在使用循环选择器的MainPage中。

*<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.. 任何有价值的解决方案请.......我已经使用了水平循环选择器,但是我没有获得如何将UIManager类中的数据绑定到水平循环选择器的方法。

    <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 请访问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/ http://blog.supaywasi.com/2011/06/horizo​​ntal-looping-selector/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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