【问题标题】:Setting Content from Code-Behind using Resources使用资源从代码隐藏设置内容
【发布时间】:2016-05-15 13:22:08
【问题描述】:

我目前正在为 UWP 应用程序设计 UI。我有一个 Splitview 设置,其中包含我想根据用户交互从代码隐藏设置的内容。

在资源中,我设置了一些菜单,我可以从内容属性本身毫无问题地设置它们:

<SplitView x:Name="NavPane" OpenPaneLength="250" CompactPaneLength="50" Content="{StaticResource Home}" DisplayMode="CompactOverlay" IsPaneOpen="False" PaneClosing="NavPane_PaneClosing">

我现在想做的是使用 content 属性绑定到代码隐藏中的 FrameworkElement 变量。

如果可能的话,如何在 xaml 中设置我的菜单?或者有没有其他人使用的我还没有掌握的方法?

非常感谢任何帮助。

【问题讨论】:

  • 您能否发布更多代码或演示项目来展示如何将菜单绑定到拆分视图?

标签: c# xaml win-universal-app xaml-resources


【解决方案1】:

看了微软的UWP系列教程,了解到数据绑定有不同的方式。更准确地说,you may check this link of Microsoft showing you different examples. 希望对你有帮助!

【讨论】:

  • 问题不在于绑定本身,而在于如何从代码隐藏中以某种方式访问​​元素。我尝试了不同的方法,但它们似乎都会产生一些错误。
猜你喜欢
  • 2014-01-28
  • 1970-01-01
  • 2010-10-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-02
  • 2016-11-14
相关资源
最近更新 更多