从Code Behind绑定时无法识别的数据绑定源 [英] Unrecognized Data Binding Source when binding from Code Behind

查看:60
本文介绍了从Code Behind绑定时无法识别的数据绑定源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我是Windows手机开发的新手。

Sir I'm a newbie to windows phone development.

我正在创建一个RSS阅读器,我想在其中生成可显示的动态枢轴

I'm creating an RSS Reader in which I want to generate dynamic pivots that would display

关于所需项目的RSS提要,我需要在后面的代码中工作。

RSS feeds about desired items, for which I need to work in the code behind .

我正在编写此代码以将数据绑定到提要文本块:

I'm writing this code to bind data to the feed text blocks:

                TextBlock feedTitle = new TextBlock();

               TextBlock feedTitle = new TextBlock();

               绑定feedTitleBinding = new Binding(" Text");

                feedTitleBinding.Source =
标题;

                feedTitleBinding.Mode = BindingMode.OneWay;

                feedTitle.SetBinding(TextBlock.TextProperty,feedTitleBinding);

                Binding feedTitleBinding = new Binding("Text");
                feedTitleBinding.Source = Title;
                feedTitleBinding.Mode = BindingMode.OneWay;
                feedTitle.SetBinding(TextBlock.TextProperty, feedTitleBinding);

                TextBlock feedSummary = new TextBlock();

               TextBlock feedSummary = new TextBlock();

               绑定feedSummaryBinding = new Binding(" Text");

                feedSummaryBinding.Source =
摘要;

                feedSummaryBinding.Mode = BindingMode.OneWay;

                feedSummary.SetBinding(TextBlock.TextProperty,feedSummaryBinding);

                Binding feedSummaryBinding = new Binding("Text");
                feedSummaryBinding.Source = Summary;
                feedSummaryBinding.Mode = BindingMode.OneWay;
                feedSummary.SetBinding(TextBlock.TextProperty, feedSummaryBinding);

其中标题摘要变量

对应于要显示的 rss feed 的标题和摘要。但是这些变量

correspond to the title and summary of the rss feed to be displayed. But these variables are

无法被visual studio识别,因为我被困住并且无法解决问题。请帮忙。

not recognized by visual studio due to which I am stuck and unable to solve the issue. Please help.

提前致谢。

推荐答案

将这些变量绑定到XAML文件中声明的静态字段(即不动态创建字段)时是否有效。

Does it work when you bind those variables to static fields declared in the XAML file (i.e. not create the fields dynamically).





这篇关于从Code Behind绑定时无法识别的数据绑定源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆