wpf - 如何在 WPF 中创建字符串列表的依赖属性?
问题描述
我找到了一些例子,但似乎没有一个有效。我正在尝试通过此依赖属性将字符串列表绑定到我的用户控件。
public IList ImageNames
{
get { return (IList)GetValue(ImageNamesProperty); }
set { SetValue(ImageNamesProperty, value); }
}
// Using a DependencyProperty as the backing store for ImageNames. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ImageNamesProperty =
DependencyProperty.Register("ImageNames", typeof(IList), typeof(DynamicWallpaperUserControl), new PropertyMetadata(new List<string>()));
在 ViewModel 中,我有一个 List String DesertImages,我将它绑定到用户控件。在 Xaml 中:
<controls:DynamicWallpaperUserControl
Background="Transparent"
ImageNames="{Binding Path=DesertImages}" />
Visual Studio 说列表是空的,尽管感谢任何帮助
解决方案
推荐阅读
- javascript - 在 mongo shell 中使用 JavaScript 将字符串拆分为对象
- neo4j - 如何升级已弃用的 Neo4J lucene 索引?
- c# - 将 json 反序列化类型更改为数组
- magento - 创建对象时发生类型错误:Peter\Extraemail\Model\Plugin\QuoteManagement\Interceptor
- javascript - firebase 不返回密钥?
- reactjs - Why useEffect dont hit infinite loop in this case?
- sql - 我无法弄清楚这些初学者 SQL 命令?
- syntax-error - 'line' 不能是变量或函数名 脚本 'Advanced RSI Strtg' 已保存
- c - c语言解释,涉及整数计算
- c++ - Must the std::condition_variable predicate be checked before waiting?