WPF Path使用Geometry数据

时间:2021-03-29 12:38:27   收藏:0   阅读:0

在某些情况下控件需要Path作为图标,此时资源字典中存入的是Geometry数据

Path pathClose = new Path();
pathClose.Data = (Geometry)new ResourceDictionary { Source = new Uri(@"Resources/Themes/Geometries.xaml", UriKind.Relative) }["t_left"];
pathClose.Fill = ResourceHelper.GetResource<SolidColorBrush>("PrimaryTextBrush");
pathClose.Width = 16;
pathClose.Height = 16;
pathClose.Stretch = Stretch.Uniform;

给定宽、高,设置Fill颜色
重要的事情说三遍
其中一定要设置pathClose.Stretch = Stretch.Uniform
其中一定要设置pathClose.Stretch = Stretch.Uniform
其中一定要设置pathClose.Stretch = Stretch.Uniform
这样就可以使Path使用Geometry数据了

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!