Loading

WPF Path使用Geometry数据

在某些情况下控件需要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数据了

posted @ 2021-03-27 18:14  Stay627  阅读(994)  评论(0编辑  收藏  举报