c# - 如何在 WPF 中将属性名称转换为框架元素?
问题描述
这是 C# 中的代码:
public static FrameworkElement GetFocusedOn(UIElement element)
{
return (FrameworkElement)element.GetValue(FocusedOnProperty);
}
我正在尝试在 VB.NET 中编写它,但它不会转换为 FrameworkElement。有任何想法吗?
解决方案
如果该FocusedOn
属性返回 a ,这应该可以工作FrameworkElement
:
Public Shared Function GetFocusedOn(ByVal element As UIElement) As FrameworkElement
Return CType(element.GetValue(FocusedOnProperty), FrameworkElement)
End Function
您想使用TryCast 运算符。
推荐阅读
- android - Android 模拟器:无法初始化 WHPX
- java - Firebase - Firestore 数据查询两次调用两次
- android - JSON 解析需要 30 秒
- c# - .Net Core 响应重定向另一个视图
- java - 无法在 adb shell 中使用 su 命令
- sql - 从一系列带有日期的发票中,我如何按发票月份和上一个发票月份汇总它们?
- sql - ORA-00904: "TYPE": 触发器上的标识符无效。我哪里出错了?
- cordova - 在科尔多瓦与 whatsapp 共享音频文件
- sql - oracle中带有时间的随机日期
- ios - 使用 UIBezierPath 的平行四边形视图