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