小智 9
您需要获取要获取颜色的元素的Background对象.在鼠标单击事件中执行此操作,如下所示:
注意:您必须检查哪种刷子类型,基本上SolidColorBrush只会真正应用,因为渐变不是简单的颜色.
示例:Brush backgroundColor = LayoutRoot.Background;
if (backgroundColor is SolidColorBrush)
{
string colorValue = ((SolidColorBrush)backgroundColor).Color.ToString();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6954 次 |
| 最近记录: |