我的XAML在这里:
<Window.Resources>
<XmlDataProvider x:Key="rssSource" XPath="//item" Source="https://news.google.com/news?output=rss" />
</Window.Resources>
我需要在按钮点击事件时更改它:
<Window.Resources>
<XmlDataProvider x:Key="rssSource" XPath="//item" Source="CHANGE WITH TEXTBOX VALUE" />
</Window.Resources>
我该怎么做?
答案 0 :(得分:1)
在按钮点击事件中放置以下行:
((XmlDataProvider)Resources["rssSource"]).Source = new Uri("<New Source>");
答案 1 :(得分:0)
像这样可能
XmlDataProvider provider = (XmlDataProvider) this.FindResource("rssSource");
provider.Source = new Uri("CHANGE WITH TEXTBOX VALUE");