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数据了


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM