我正在尝试从资源字典中获取x:key或x:name,但我没有设法找到合适的解决方案来实现这一目标。
我的词典定义如下:
< ResourceDictionary x:Class="com.mycompany.WpfCore.ResourceDictionaries.ThemedControls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="TestName">
</ResourceDictionary>
我将其访问到IValueConverter:
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
ResourceDictionary dic = value as ResourceDictionary;
if (dico == null)
{
return "NaN";
}
else
{
return dico.GetType().Name;
}
}
目前此代码返回我&#34; ThemedControls&#34; name,但我想从x:key或x:Name。
获取名称有什么想法吗?