English 中文(简体)
• 如何在银灯以方案方式填充数据条目清单Box?
原标题:How to fill ListBox with data entries programatically in Silverlight?

为了填补清单框表,我撰写了以下代码:

protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            TestDBContext context = new TestDBContext();
            context.Load(context.GetTaskQuery());

        var taskList = GetTasks();
        foreach (var t in taskList)
        {
            ListBoxTaskItems.Items.Add(t);

        }
    }

    private List<TaskItem> GetTasks()
    {
        var tasks = from t in context.Tasks
                    select new TaskItem(t);
        return tasks.ToList();
    }

问题在于,上岸的代码是空洞的Box。 是否有任何人知道如何修改现行法典,或以另一种方式以方案方式用数据条目填写清单箱?

www.un.org/Depts/DGACM/index_spanish.htm Edit #1: 我在总结时注意到,GetTasks()方法在背景之前已经执行。 GetTask Query () and I gues this is the causes of an separate ListBox. 然而,我不知道如何确定该守则,以便把名单Box列入其中。

谢谢!

最佳回答

Somebody posted another solution, then for whatever reason deleted it, but that might work better. I just tried it in some code I m working on and found it was faster:

Binding bind = new Binding();

bind.Source = GetTasks();

ListBoxTaskItems.SetBinding(ListBox.ItemsSourceProperty, bind);

(附上声明)。

问题回答

我在你的发言中试图这样做:

ListBoxItem listBoxItem = new ListBoxItem();

listBoxItem.Content = t;

ListBoxTaskItems.Items.Add(listBoxItem);

我也做了类似的事情,在把Grids添入一个名单Box时,只要一个任务项目与应该做的内容一样是可以接受的。





相关问题
Silverlight Rich text box control

Our team decided that we need our own custom Rich text box control for Silverlight app we are developing. We looked at existing controls mentioned at A good rich text control for Silverlight but ...

Silverlight ImageBrush not rendering (with Bing Map Control)

I m trying to add an image to a Pushpin instance from the Silverlight Bing Map Control, but I can t seem to get it to render (the pushpin renders fine). This is probably a general WPF question rather ...

Silverlight OpenFileDialog DoEvents equivalent

I m processing large files after they are selected by the user. My code looks like the following: if (FileDialog.ShowDialog() == true) { // process really big file } This freezes up the UI so ...

list of controls with templates in silverlight

Does anyone know where to find a list of controls that you can set the template on in Silverlight? I ve wasted several hours now trying to create control templates only to find that the control doesn ...

Silverlight, Updating the UI during processing

I have a simple silverlight multifile upload application, and i want to provide the user with some feedback, right now its only in a test phase and i dont have the webservice. Somehow i cant get the ...

Silverlight 3 - FindName returns null

This looks a bug to me.. Using Silverlight 3 and i have a user control defined in XAML and trying to access the object during runtime returns a null. <Grid> <common:CommonGridEditPanel x:...

silverlight 3 collection binding

Someone please help me understand why this binding does not work... I have a class called SelectionManager with a property called dates which is populated by a WCF service. The property is an ...

热门标签