用DependanceProperty做Dynamic换Icon
1:做Icon用Canvas还是DrawingBrush?
Canvas的例子:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Canvas Width="48.038467974024" Height="45.1787736967389" x:Key="applicationsinternet"> <Canvas Canvas.Left="-3.1743200497011" Canvas.Top="-2.63605017375272"> <Canvas> <Path Data="F1M45.052803,38.908627A20.203051,7.4751287,0,1,1,4.6467018,38.908627A20.203051,7.4751287,0,1,1,45.052803,38.908627z" Stroke="{x:Null}" StrokeThickness="1"> <Path.Fill> <RadialGradientBrush Center="15.115514,63.965388" RadiusX="12.289036" RadiusY="12.289036" GradientOrigin="15.115514,63.965388" MappingMode="Absolute"> <RadialGradientBrush.GradientStops> <GradientStop Color="#FF000000" Offset="0" /> <GradientStop Color="#00000000" Offset="1" /> </RadialGradientBrush.GradientStops> <RadialGradientBrush.Transform> <MatrixTransform Matrix="1.64399003982544,0,0,0.608276009559631,0,0" /> </RadialGradientBrush.Transform> </RadialGradientBrush> </Path.Fill> <Path.RenderTransform> <MatrixTransform Matrix="1,0,0,1.24324405193329,0,-10.2724103927612" /> </Path.RenderTransform> </Path> <Path Data="F1M43.959853,23.485499C43.959853,34.195217 35.27775,42.877222 24.569505,42.877222 13.860279,42.877222 5.1786663,34.195119 5.1786663,23.485499 5.1786663,12.776272 13.860279,4.0951517 24.569505,4.0951517 35.27775,4.0951517 43.959853,12.776272 43.959853,23.485499L43.959853,23.485499z" Stroke="#FF39396C" StrokeThickness="1" StrokeMiterLimit="4"> <Path.Fill> <RadialGradientBrush Center="18.247644,15.716079" RadiusX="29.993349" RadiusY="29.993349" GradientOrigin="18.247644,15.716079" MappingMode="Absolute"> <RadialGradientBrush.GradientStops> <GradientStop Color="#FFD3E9FF" Offset="0" /> <GradientStop Color="#FFD3E9FF" Offset="0.15517240762710571" /> <GradientStop Color="#FF4074AE" Offset="0.75" /> <GradientStop Color="#FF36486C" Offset="1" /> </RadialGradientBrush.GradientStops> </RadialGradientBrush> </Path.Fill> </Path> <Canvas> <Canvas> <Canvas> <Path Data="F1M44.0713,20.7144C44.0713,20.9771,44.0713,20.7144,44.0713,20.7144L43.5264,21.3316C43.1924,20.938,42.8174,20.607,42.4366,20.2613L41.6007,20.3843 40.837,19.521 40.837,20.5894 41.4913,21.0845 41.9268,21.5777 42.5088,20.9195C42.6553,21.1939,42.7998,21.4683,42.9453,21.7427L42.9453,22.565 42.29,23.3052 41.0908,24.1284 40.1826,25.0347 39.6006,24.3745 39.8916,23.6343 39.3105,22.9761 38.3291,20.8784 37.4932,19.9331 37.2744,20.1792 37.6025,21.3726 38.2197,22.0718C38.5722,23.0894 38.9209,24.062 39.3838,25.0347 40.1016,25.0347 40.7783,24.9585 41.4912,24.8687L41.4912,25.4449 40.6191,27.5841 39.8193,28.4884 39.165,29.8888C39.165,30.6564,39.165,31.424,39.165,32.1915L39.3838,33.0978 39.0205,33.508 38.2197,34.0021 37.3838,34.7013 38.0752,35.4826 37.1299,36.3068 37.3115,36.84 35.8935,38.4455 34.9492,38.4455 34.1494,38.9396 33.6396,38.9396 33.6396,38.2814 33.4228,36.963C33.1415,36.1368 32.8486,35.3165 32.5507,34.4962 32.5507,33.8907 32.5868,33.2911 32.623,32.6857L32.9873,31.8634 32.4775,30.8751 32.5146,29.5177 31.8232,28.7364 32.1689,27.6055 31.6064,26.9673 30.624,26.9673 30.2969,26.5972 29.3155,27.2149 28.9161,26.7613 28.0069,27.543C27.3897,26.8433,26.7715,26.1441,26.1534,25.4449L25.4268,23.7164 26.0811,22.7301 25.7178,22.319 26.5166,20.4254C27.1729,19.609,27.8584,18.8258,28.5518,18.0397L29.7881,17.7106 31.169,17.5465 32.1143,17.7936 33.459,19.15 33.9317,18.6158 34.585,18.5338 35.8213,18.9449 36.7666,18.9449 37.4209,18.3687 37.7119,17.9576 37.0566,17.5465 35.9658,17.4645C35.6631,17.0446,35.3818,16.6032,35.0224,16.2301L34.6581,16.3942 34.5126,17.4645 33.8583,16.7243 33.7138,15.9001 32.9872,15.3259 32.6952,15.3259 33.4227,16.1482 33.1317,16.8884 32.5506,17.0525 32.9139,16.3123 32.2586,15.9842 31.6785,15.326 30.5867,15.5721 30.4422,15.9002 29.7879,16.3123 29.4246,17.2176 28.5164,17.6697 28.116,17.2176 27.6805,17.2176 27.6805,15.7362 28.6258,15.2421 29.3524,15.2421 29.2059,14.6669 28.6258,14.0907 29.6063,13.8846 30.1512,13.2684 30.5867,12.5272 31.3875,12.5272 31.1687,11.952 31.6785,11.6229 31.6785,12.2811 32.7683,12.5272 33.8581,11.6229 33.9313,11.2108 34.8756,10.5531C34.5338,10.5956,34.192,10.6268,33.858,10.7177L33.858,9.9766 34.2213,9.1538 33.858,9.1538 33.0596,9.894 32.8408,10.3056 33.0596,10.8823 32.6953,11.8686 32.1142,11.5395 31.6064,10.9643 30.8056,11.5395 30.5146,10.2236 31.8955,9.3188 31.8955,8.8247 32.7685,8.249 34.1494,7.9194 35.0947,8.249 36.8388,8.5781 36.4033,9.0713 35.458,9.0713 36.4033,10.0586 37.1299,9.2363 37.3506,8.8745C37.3506,8.8745 40.1377,11.3725 41.7305,14.105 43.3233,16.8384 44.0713,20.0601 44.0713,20.7144z" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> </Canvas> <Canvas> <Canvas> <Path Data="F1M26.0703,9.2363L25.9971,9.7295 26.5069,10.0586 27.378,9.4829 26.9425,8.9892 26.3605,9.3188 26.0705,9.2363" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> </Canvas> <Canvas> <Canvas> <Path Data="F1M26.8701,5.8633L24.9795,5.1226 22.7998,5.3692 20.1094,6.1094 19.6006,6.6035 21.2725,7.7549 21.2725,8.4131 20.6182,9.0713 21.4912,10.8003 22.0713,10.4702 22.7998,9.3188C23.9228,8.9716,24.9297,8.5781,25.9971,8.0844L26.8701,5.8632" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> </Canvas> <Canvas> <Canvas> <Path Data="F1M28.833,12.7749L28.542,12.0337 28.0322,12.1987 28.1787,13.103 28.833,12.7749" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> </Canvas> <Canvas> <Canvas> <Path Data="F1M29.123,12.6089L28.9775,13.5972 29.7773,13.4322 30.3584,12.857 29.8496,12.3629C29.6787,11.9078,29.4824,11.483,29.2685,11.0465L28.833,11.0465 28.833,11.5397 29.123,11.8688 29.123,12.609" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> </Canvas> <Canvas> <Canvas> <Path Data="F1M18.3652,28.2422L17.7832,27.0899 16.6929,26.8433 16.1114,25.2808 14.6578,25.4449 13.4224,24.5406 12.1133,25.692 12.1133,25.8736C11.7173,25.7593,11.2305,25.7437,10.8779,25.5269L10.5869,24.7046 10.5869,23.7993 9.7148,23.8813C9.7876,23.3051,9.8598,22.7299,9.9331,22.1538L9.4238,22.1538 8.9155,22.812 8.4062,23.0581 7.6791,22.6479 7.6063,21.7426 7.7518,20.7553 8.8426,19.933 9.7147,19.933 9.8597,19.4389 10.95,19.685 11.7498,20.6733 11.8953,19.0268 13.2766,17.8754 13.7854,16.641 14.803,16.2299 15.3845,15.4076 16.6926,15.1596 17.3474,14.1733C16.6931,14.1733,16.0388,14.1733,15.3845,14.1733L16.6203,13.5971 17.4919,13.5971 18.7282,13.185 18.8737,12.6928 18.4372,12.2807 17.9284,12.1157 18.0739,11.6225 17.7106,10.8823 16.838,11.2104 16.9835,10.5527 15.9659,9.9765 15.1666,11.3744 15.2389,11.8685 14.4396,12.1986 13.9303,13.2679 13.7125,12.2806 12.3312,11.7044 12.1129,10.9642 13.9303,9.8939 14.7301,9.1537 14.8029,8.2489 14.3669,8.0018 13.7854,7.9193 13.4221,8.8246C13.4221,8.8246 12.8142,8.9437 12.6579,8.9823 10.6618,10.8217 6.6286,14.7924 5.6916,22.2885 5.7287,22.4623 6.3708,23.4701 6.3708,23.4701L7.8972,24.3744 9.4236,24.7865 10.0784,25.6097 11.0955,26.3499 11.677,26.2679 12.113,26.4642 12.113,26.597 11.5319,28.16 11.0954,28.8182 11.2409,29.1483 10.8776,30.3807 12.1862,32.7674 13.4943,33.9197 14.0763,34.742 14.0031,36.4705 14.4396,37.4568 14.0031,39.3494C14.0031,39.3494 13.9689,39.3377 14.0246,39.5271 14.0808,39.7166 16.3537,40.9783 16.4982,40.8709 16.6422,40.7615 16.7653,40.6658 16.7653,40.6658L16.6203,40.2556 17.2014,39.6794 17.4197,39.1032 18.365,38.7731 19.0916,36.9626 18.8738,36.4704 19.3816,35.7302 20.4724,35.4822 21.0544,34.1658 20.9089,32.5213 21.781,31.2869 21.9265,30.0525C20.7331,29.4607,19.5495,28.8513,18.365,28.242" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> </Canvas> <Canvas> <Canvas> <Path Data="F1M16.7656,9.5649L17.4922,10.0586 18.0742,10.0586 18.0742,9.4829 17.3476,9.1538 16.7656,9.5649" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> </Canvas> <Canvas> <Canvas> <Path Data="F1M14.876,8.9072L14.5122,9.812 15.2393,9.812 15.6031,8.9892C15.9166,8.7675,16.2286,8.5444,16.5479,8.331L17.275,8.5781C17.7594,8.9072,18.2438,9.2363,18.7286,9.5649L19.4561,8.9072 18.6558,8.5781 18.292,7.8374 16.9111,7.6728 16.8383,7.2612 16.184,7.4262 15.8936,8.002 15.5298,7.2613 15.3848,7.5904 15.4576,8.4132 14.876,8.9072" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> </Canvas> <Canvas> <Canvas Opacity="0.75"> <Path Data="F1" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> <Canvas> <Path Data="F1" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> </Canvas> <Canvas> <Canvas Opacity="0.75"> <Path Data="F1" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> <Canvas> <Path Data="F1" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> </Canvas> <Canvas> <Canvas> <Path Data="F1M17.4922,6.8496L17.856,6.521 18.5831,6.3564C19.0811,6.1142,19.5811,5.9511,20.1095,5.7802L19.8195,5.2865 18.881,5.4213 18.4376,5.8632 17.7066,5.9692 17.0567,6.2744 16.7408,6.4272 16.5479,6.6855 17.4922,6.8496" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> </Canvas> <Canvas> <Canvas> <Path Data="F1M18.7285,14.6665L19.165,14.0083 18.5102,13.5151 18.7285,14.6665" Fill="#B6204A87" Stroke="{x:Null}" StrokeThickness="1" /> </Canvas> </Canvas> <Canvas.RenderTransform> <MatrixTransform Matrix="0.982370972633362,0,0,0.982370972633362,0.121078997850418,0.232914000749588" /> </Canvas.RenderTransform> </Canvas> <Path Data="F1M42.975093,23.485534C42.975093,33.651354 34.733915,41.89244 24.569493,41.89244 14.404139,41.89244 6.1634261,33.651261 6.1634261,23.485534 6.1634261,13.32018 14.404139,5.079934 24.569493,5.079934 34.733915,5.079934 42.975093,13.32018 42.975093,23.485534L42.975093,23.485534z" Fill="{x:Null}" StrokeThickness="1" StrokeMiterLimit="4" Opacity="0.3956044"> <Path.Stroke> <RadialGradientBrush Center="15.601279,12.142302" RadiusX="43.526714" RadiusY="43.526714" GradientOrigin="15.601279,12.142302" MappingMode="Absolute"> <RadialGradientBrush.GradientStops> <GradientStop Color="#FFFFFFFF" Offset="0" /> <GradientStop Color="#2AFFFFFF" Offset="1" /> </RadialGradientBrush.GradientStops> </RadialGradientBrush> </Path.Stroke> </Path> <Path Data="M-2.8284283,21.041553A15.733126,9.4575529,0,1,1,-34.29468,21.041553A15.733126,9.4575529,0,1,1,-2.8284283,21.041553z" Fill="{x:Null}" StrokeThickness="0.881641983985901" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round" StrokeMiterLimit="4"> <Path.Stroke> <LinearGradientBrush StartPoint="-25.176178,30.057165" EndPoint="-22.252472,21.041553" MappingMode="Absolute" SpreadMethod="Pad"> <LinearGradientBrush.GradientStops> <GradientStop Color="#FFFFFFFF" Offset="0" /> <GradientStop Color="#00FFFFFF" Offset="1" /> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Path.Stroke> <Path.RenderTransform> <MatrixTransform Matrix="1.13103401660919,0.613097012042999,-0.476556003093719,0.879144012928009,54.0905799865723,16.0443496704102" /> </Path.RenderTransform> </Path> <Path Data="M-2.8284283,21.041553A15.733126,9.4575529,0,1,1,-34.29468,21.041553A15.733126,9.4575529,0,1,1,-2.8284283,21.041553z" Fill="{x:Null}" StrokeThickness="0.881641983985901" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round" StrokeMiterLimit="4"> <Path.Stroke> <LinearGradientBrush StartPoint="-25.176178,30.057165" EndPoint="-22.113543,22.661524" MappingMode="Absolute" SpreadMethod="Pad"> <LinearGradientBrush.GradientStops> <GradientStop Color="#FFFFFFFF" Offset="0" /> <GradientStop Color="#00FFFFFF" Offset="1" /> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Path.Stroke> <Path.RenderTransform> <MatrixTransform Matrix="0.939325988292694,-0.879086017608643,0.683306992053986,0.730130970478058,32.3140602111816,-4.45156097412109" /> </Path.RenderTransform> </Path> <Canvas> <Path Data="M18.788838,12.493138A6.7175145,6.7175145,0,1,1,5.3538089,12.493138A6.7175145,6.7175145,0,1,1,18.788838,12.493138z" Stroke="{x:Null}" StrokeThickness="1"> <Path.Fill> <RadialGradientBrush Center="12.071323,12.493138" RadiusX="6.7175145" RadiusY="6.7175145" GradientOrigin="12.071323,12.493138" MappingMode="Absolute"> <RadialGradientBrush.GradientStops> <GradientStop Color="#FFFFFFFF" Offset="0" /> <GradientStop Color="#00FFFFFF" Offset="1" /> </RadialGradientBrush.GradientStops> </RadialGradientBrush> </Path.Fill> <Path.RenderTransform> <MatrixTransform Matrix="1,0,0,1,14.9502601623535,22.9304695129395" /> </Path.RenderTransform> </Path> <Path Data="M18.788838,12.493138A6.7175145,6.7175145,0,1,1,5.3538089,12.493138A6.7175145,6.7175145,0,1,1,18.788838,12.493138z" Fill="#FFFFFFFF" Stroke="{x:Null}" StrokeThickness="1"> <Path.RenderTransform> <MatrixTransform Matrix="0.308270990848541,0,0,0.308270990848541,23.300350189209,31.5723400115967" /> </Path.RenderTransform> </Path> <Canvas.RenderTransform> <MatrixTransform Matrix="-1.04577195644379,0.767251014709473,0.767251014709473,1.04577195644379,35.6165084838867,-22.1439609527588" /> </Canvas.RenderTransform> </Canvas> <Path Data="M-2.8284283,21.041553A15.733126,9.4575529,0,1,1,-34.29468,21.041553A15.733126,9.4575529,0,1,1,-2.8284283,21.041553z" Fill="{x:Null}" StrokeThickness="0.881641983985901" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round" StrokeMiterLimit="4"> <Path.Stroke> <LinearGradientBrush StartPoint="-22.822565,28.337734" EndPoint="-22.113543,22.661524" MappingMode="Absolute" SpreadMethod="Pad"> <LinearGradientBrush.GradientStops> <GradientStop Color="#FFFFFFFF" Offset="0" /> <GradientStop Color="#00FFFFFF" Offset="1" /> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Path.Stroke> <Path.RenderTransform> <MatrixTransform Matrix="-1.28031599521637,-0.126158997416496,0.0980622544884682,-0.995180010795593,-2.40512490272522,40.523868560791" /> </Path.RenderTransform> </Path> <Path Data="M-2.8284283,21.041553A15.733126,9.4575529,0,1,1,-34.29468,21.041553A15.733126,9.4575529,0,1,1,-2.8284283,21.041553z" Fill="{x:Null}" StrokeThickness="0.90226137638092" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round" StrokeMiterLimit="4"> <Path.Stroke> <LinearGradientBrush StartPoint="-21.658581,15.649428" EndPoint="-21.962101,21.336346" MappingMode="Absolute" SpreadMethod="Pad"> <LinearGradientBrush.GradientStops> <GradientStop Color="#FFFFFFFF" Offset="0" /> <GradientStop Color="#00FFFFFF" Offset="1" /> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Path.Stroke> <Path.RenderTransform> <MatrixTransform Matrix="0.917873978614807,-0.858982980251312,0.667701005935669,0.713433027267456,27.6331691741943,-6.9090690612793" /> </Path.RenderTransform> </Path> <Canvas> <Path Data="M18.788838,12.493138A6.7175145,6.7175145,0,1,1,5.3538089,12.493138A6.7175145,6.7175145,0,1,1,18.788838,12.493138z" Stroke="{x:Null}" StrokeThickness="1"> <Path.Fill> <RadialGradientBrush Center="12.071323,12.493138" RadiusX="6.7175145" RadiusY="6.7175145" GradientOrigin="12.071323,12.493138" MappingMode="Absolute"> <RadialGradientBrush.GradientStops> <GradientStop Color="#FFFFFFFF" Offset="0" /> <GradientStop Color="#00FFFFFF" Offset="1" /> </RadialGradientBrush.GradientStops> </RadialGradientBrush> </Path.Fill> <Path.RenderTransform> <MatrixTransform Matrix="1,0,0,1,14.9502601623535,22.9304695129395" /> </Path.RenderTransform> </Path> <Path Data="M18.788838,12.493138A6.7175145,6.7175145,0,1,1,5.3538089,12.493138A6.7175145,6.7175145,0,1,1,18.788838,12.493138z" Fill="#FFFFFFFF" Stroke="{x:Null}" StrokeThickness="1"> <Path.RenderTransform> <MatrixTransform Matrix="0.308270990848541,0,0,0.308270990848541,23.300350189209,31.5723400115967" /> </Path.RenderTransform> </Path> <Canvas.RenderTransform> <MatrixTransform Matrix="-0.806276023387909,0.591539978981018,0.591539978981018,0.806276023387909,12.3856401443481,-18.0292091369629" /> </Canvas.RenderTransform> </Canvas> <Canvas> <Path Data="M18.788838,12.493138A6.7175145,6.7175145,0,1,1,5.3538089,12.493138A6.7175145,6.7175145,0,1,1,18.788838,12.493138z" Stroke="{x:Null}" StrokeThickness="1"> <Path.Fill> <RadialGradientBrush Center="12.071323,12.493138" RadiusX="6.7175145" RadiusY="6.7175145" GradientOrigin="12.071323,12.493138" MappingMode="Absolute"> <RadialGradientBrush.GradientStops> <GradientStop Color="#FFFFFFFF" Offset="0" /> <GradientStop Color="#00FFFFFF" Offset="1" /> </RadialGradientBrush.GradientStops> </RadialGradientBrush> </Path.Fill> <Path.RenderTransform> <MatrixTransform Matrix="1,0,0,1,14.9502601623535,22.9304695129395" /> </Path.RenderTransform> </Path> <Path Data="M18.788838,12.493138A6.7175145,6.7175145,0,1,1,5.3538089,12.493138A6.7175145,6.7175145,0,1,1,18.788838,12.493138z" Fill="#FFFFFFFF" Stroke="{x:Null}" StrokeThickness="1"> <Path.RenderTransform> <MatrixTransform Matrix="0.308270990848541,0,0,0.308270990848541,23.300350189209,31.5723400115967" /> </Path.RenderTransform> </Path> <Canvas.RenderTransform> <MatrixTransform Matrix="-0.806276023387909,0.591539978981018,0.591539978981018,0.806276023387909,13.4990997314453,-31.5002193450928" /> </Canvas.RenderTransform> </Canvas> <Canvas> <Path Data="M18.788838,12.493138A6.7175145,6.7175145,0,1,1,5.3538089,12.493138A6.7175145,6.7175145,0,1,1,18.788838,12.493138z" Stroke="{x:Null}" StrokeThickness="1"> <Path.Fill> <RadialGradientBrush Center="12.071323,12.493138" RadiusX="6.7175145" RadiusY="6.7175145" GradientOrigin="12.071323,12.493138" MappingMode="Absolute"> <RadialGradientBrush.GradientStops> <GradientStop Color="#FFFFFFFF" Offset="0" /> <GradientStop Color="#00FFFFFF" Offset="1" /> </RadialGradientBrush.GradientStops> </RadialGradientBrush> </Path.Fill> <Path.RenderTransform> <MatrixTransform Matrix="1,0,0,1,14.9502601623535,22.9304695129395" /> </Path.RenderTransform> </Path> <Path Data="M18.788838,12.493138A6.7175145,6.7175145,0,1,1,5.3538089,12.493138A6.7175145,6.7175145,0,1,1,18.788838,12.493138z" Fill="#FFFFFFFF" Stroke="{x:Null}" StrokeThickness="1"> <Path.RenderTransform> <MatrixTransform Matrix="0.308270990848541,0,0,0.308270990848541,23.300350189209,31.5723400115967" /> </Path.RenderTransform> </Path> <Canvas.RenderTransform> <MatrixTransform Matrix="-0.870226979255676,0.638571977615356,0.638458013534546,0.870380997657776,25.2050304412842,-35.3127784729004" /> </Canvas.RenderTransform> </Canvas> </Canvas> </Canvas> </Canvas> </ResourceDictionary>
DrawingBrush的例子:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"> <SolidColorBrush x:Key="Brush1" Color="#B6204A87" /> <SolidColorBrush x:Key="Brush2" Color="White" /> <DrawingBrush x:Key="applicationsinternet" Stretch="Uniform"> <DrawingBrush.Drawing> <DrawingGroup> <DrawingGroup> <DrawingGroup Transform="1,0,0,1.24324405193329,0,-10.2724103927612"> <GeometryDrawing Geometry="F1M45.053,38.909A20.203,7.475,0.000,1,1,4.647,38.909A20.203,7.475,0.000,1,1,45.053,38.909z"> <GeometryDrawing.Brush> <RadialGradientBrush Center="15.116,63.965" RadiusX="12.289" RadiusY="12.289" GradientOrigin="15.116,63.965" MappingMode="Absolute" Transform="1.64399003982544,0,0,0.608276009559631,0,0"> <GradientStop Color="Black" Offset="0" /> <GradientStop Color="#00000000" Offset="1" /> </RadialGradientBrush> </GeometryDrawing.Brush> </GeometryDrawing> </DrawingGroup> <GeometryDrawing Geometry="F1M43.960,23.485C43.960,34.195 35.278,42.877 24.570,42.877 13.860,42.877 5.179,34.195 5.179,23.485 5.179,12.776 13.860,4.095 24.570,4.095 35.278,4.095 43.960,12.776 43.960,23.485L43.960,23.485z"> <GeometryDrawing.Brush> <RadialGradientBrush Center="18.248,15.716" RadiusX="29.993" RadiusY="29.993" GradientOrigin="18.248,15.716" MappingMode="Absolute"> <GradientStop Color="#FFD3E9FF" Offset="0" /> <GradientStop Color="#FFD3E9FF" Offset="0.155" /> <GradientStop Color="#FF4074AE" Offset="0.75" /> <GradientStop Color="#FF36486C" Offset="1" /> </RadialGradientBrush> </GeometryDrawing.Brush> <GeometryDrawing.Pen> <Pen Brush="#FF39396C" Thickness="1" MiterLimit="4" /> </GeometryDrawing.Pen> </GeometryDrawing> <DrawingGroup Transform="0.982370972633362,0,0,0.982370972633362,0.121078997850418,0.232914000749588"> <DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M44.071,20.714C44.071,20.977,44.071,20.714,44.071,20.714L43.526,21.332C43.192,20.938,42.817,20.607,42.437,20.261L41.601,20.384 40.837,19.521 40.837,20.589 41.491,21.085 41.927,21.578 42.509,20.920C42.655,21.194,42.800,21.468,42.945,21.743L42.945,22.565 42.290,23.305 41.091,24.128 40.183,25.035 39.601,24.375 39.892,23.634 39.311,22.976 38.329,20.878 37.493,19.933 37.274,20.179 37.603,21.373 38.220,22.072C38.572,23.089 38.921,24.062 39.384,25.035 40.102,25.035 40.778,24.959 41.491,24.869L41.491,25.445 40.619,27.584 39.819,28.488 39.165,29.889C39.165,30.656,39.165,31.424,39.165,32.192L39.384,33.098 39.021,33.508 38.220,34.002 37.384,34.701 38.075,35.483 37.130,36.307 37.312,36.840 35.894,38.446 34.949,38.446 34.149,38.940 33.640,38.940 33.640,38.281 33.423,36.963C33.142,36.137 32.849,35.317 32.551,34.496 32.551,33.891 32.587,33.291 32.623,32.686L32.987,31.863 32.478,30.875 32.515,29.518 31.823,28.736 32.169,27.606 31.606,26.967 30.624,26.967 30.297,26.597 29.316,27.215 28.916,26.761 28.007,27.543C27.390,26.843,26.772,26.144,26.153,25.445L25.427,23.716 26.081,22.730 25.718,22.319 26.517,20.425C27.173,19.609,27.858,18.826,28.552,18.040L29.788,17.711 31.169,17.547 32.114,17.794 33.459,19.150 33.932,18.616 34.585,18.534 35.821,18.945 36.767,18.945 37.421,18.369 37.712,17.958 37.057,17.547 35.966,17.465C35.663,17.045,35.382,16.603,35.022,16.230L34.658,16.394 34.513,17.465 33.858,16.724 33.714,15.900 32.987,15.326 32.695,15.326 33.423,16.148 33.132,16.888 32.551,17.053 32.914,16.312 32.259,15.984 31.679,15.326 30.587,15.572 30.442,15.900 29.788,16.312 29.425,17.218 28.516,17.670 28.116,17.218 27.681,17.218 27.681,15.736 28.626,15.242 29.352,15.242 29.206,14.667 28.626,14.091 29.606,13.885 30.151,13.268 30.587,12.527 31.388,12.527 31.169,11.952 31.679,11.623 31.679,12.281 32.768,12.527 33.858,11.623 33.931,11.211 34.876,10.553C34.534,10.596,34.192,10.627,33.858,10.718L33.858,9.977 34.221,9.154 33.858,9.154 33.060,9.894 32.841,10.306 33.060,10.882 32.695,11.869 32.114,11.540 31.606,10.964 30.806,11.540 30.515,10.224 31.896,9.319 31.896,8.825 32.769,8.249 34.149,7.919 35.095,8.249 36.839,8.578 36.403,9.071 35.458,9.071 36.403,10.059 37.130,9.236 37.351,8.875C37.351,8.875 40.138,11.373 41.731,14.105 43.323,16.838 44.071,20.060 44.071,20.714z" /> </DrawingGroup> </DrawingGroup> <DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M26.070,9.236L25.997,9.730 26.507,10.059 27.378,9.483 26.943,8.989 26.361,9.319 26.071,9.236" /> </DrawingGroup> </DrawingGroup> <DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M26.870,5.863L24.980,5.123 22.800,5.369 20.109,6.109 19.601,6.604 21.273,7.755 21.273,8.413 20.618,9.071 21.491,10.800 22.071,10.470 22.800,9.319C23.923,8.972,24.930,8.578,25.997,8.084L26.870,5.863" /> </DrawingGroup> </DrawingGroup> <DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M28.833,12.775L28.542,12.034 28.032,12.199 28.179,13.103 28.833,12.775" /> </DrawingGroup> </DrawingGroup> <DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M29.123,12.609L28.978,13.597 29.777,13.432 30.358,12.857 29.850,12.363C29.679,11.908,29.482,11.483,29.269,11.047L28.833,11.047 28.833,11.540 29.123,11.869 29.123,12.609" /> </DrawingGroup> </DrawingGroup> <DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M18.365,28.242L17.783,27.090 16.693,26.843 16.111,25.281 14.658,25.445 13.422,24.541 12.113,25.692 12.113,25.874C11.717,25.759,11.231,25.744,10.878,25.527L10.587,24.705 10.587,23.799 9.715,23.881C9.788,23.305,9.860,22.730,9.933,22.154L9.424,22.154 8.916,22.812 8.406,23.058 7.679,22.648 7.606,21.743 7.752,20.755 8.843,19.933 9.715,19.933 9.860,19.439 10.950,19.685 11.750,20.673 11.895,19.027 13.277,17.875 13.785,16.641 14.803,16.230 15.385,15.408 16.693,15.160 17.347,14.173C16.693,14.173,16.039,14.173,15.385,14.173L16.620,13.597 17.492,13.597 18.728,13.185 18.874,12.693 18.437,12.281 17.928,12.116 18.074,11.623 17.711,10.882 16.838,11.210 16.984,10.553 15.966,9.977 15.167,11.374 15.239,11.869 14.440,12.199 13.930,13.268 13.713,12.281 12.331,11.704 12.113,10.964 13.930,9.894 14.730,9.154 14.803,8.249 14.367,8.002 13.785,7.919 13.422,8.825C13.422,8.825 12.814,8.944 12.658,8.982 10.662,10.822 6.629,14.792 5.692,22.289 5.729,22.462 6.371,23.470 6.371,23.470L7.897,24.374 9.424,24.787 10.078,25.610 11.096,26.350 11.677,26.268 12.113,26.464 12.113,26.597 11.532,28.160 11.095,28.818 11.241,29.148 10.878,30.381 12.186,32.767 13.494,33.920 14.076,34.742 14.003,36.471 14.440,37.457 14.003,39.349C14.003,39.349 13.969,39.338 14.025,39.527 14.081,39.717 16.354,40.978 16.498,40.871 16.642,40.762 16.765,40.666 16.765,40.666L16.620,40.256 17.201,39.679 17.420,39.103 18.365,38.773 19.092,36.963 18.874,36.470 19.382,35.730 20.472,35.482 21.054,34.166 20.909,32.521 21.781,31.287 21.927,30.053C20.733,29.461,19.550,28.851,18.365,28.242" /> </DrawingGroup> </DrawingGroup> <DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M16.766,9.565L17.492,10.059 18.074,10.059 18.074,9.483 17.348,9.154 16.766,9.565" /> </DrawingGroup> </DrawingGroup> <DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M14.876,8.907L14.512,9.812 15.239,9.812 15.603,8.989C15.917,8.768,16.229,8.544,16.548,8.331L17.275,8.578C17.759,8.907,18.244,9.236,18.729,9.565L19.456,8.907 18.656,8.578 18.292,7.837 16.911,7.673 16.838,7.261 16.184,7.426 15.894,8.002 15.530,7.261 15.385,7.590 15.458,8.413 14.876,8.907" /> </DrawingGroup> </DrawingGroup> <DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1" /> </DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1" /> </DrawingGroup> </DrawingGroup> <DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1" /> </DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1" /> </DrawingGroup> </DrawingGroup> <DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M17.492,6.850L17.856,6.521 18.583,6.356C19.081,6.114,19.581,5.951,20.110,5.780L19.820,5.287 18.881,5.421 18.438,5.863 17.707,5.969 17.057,6.274 16.741,6.427 16.548,6.686 17.492,6.850" /> </DrawingGroup> </DrawingGroup> <DrawingGroup> <DrawingGroup> <GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1M18.729,14.667L19.165,14.008 18.510,13.515 18.729,14.667" /> </DrawingGroup> </DrawingGroup> </DrawingGroup> <GeometryDrawing Geometry="F1M42.975,23.486C42.975,33.651 34.734,41.892 24.569,41.892 14.404,41.892 6.163,33.651 6.163,23.486 6.163,13.320 14.404,5.080 24.569,5.080 34.734,5.080 42.975,13.320 42.975,23.486L42.975,23.486z"> <GeometryDrawing.Pen> <Pen Thickness="1" MiterLimit="4"> <Pen.Brush> <RadialGradientBrush Center="15.601,12.142" RadiusX="43.527" RadiusY="43.527" GradientOrigin="15.601,12.142" MappingMode="Absolute"> <GradientStop Color="White" Offset="0" /> <GradientStop Color="#2AFFFFFF" Offset="1" /> </RadialGradientBrush> </Pen.Brush> </Pen> </GeometryDrawing.Pen> </GeometryDrawing> <DrawingGroup Transform="1.13103401660919,0.613097012042999,-0.476556003093719,0.879144012928009,54.0905799865723,16.0443496704102"> <GeometryDrawing Geometry="M-2.828,21.042A15.733,9.458,0.000,1,1,-34.295,21.042A15.733,9.458,0.000,1,1,-2.828,21.042z"> <GeometryDrawing.Pen> <Pen Thickness="0.882" StartLineCap="Round" EndLineCap="Round" DashCap="Round" LineJoin="Round" MiterLimit="4"> <Pen.Brush> <LinearGradientBrush StartPoint="-25.176,30.057" EndPoint="-22.252,21.042" MappingMode="Absolute" SpreadMethod="Pad"> <GradientStop Color="White" Offset="0" /> <GradientStop Color="Transparent" Offset="1" /> </LinearGradientBrush> </Pen.Brush> </Pen> </GeometryDrawing.Pen> </GeometryDrawing> </DrawingGroup> <DrawingGroup Transform="0.939325988292694,-0.879086017608643,0.683306992053986,0.730130970478058,32.3140602111816,-4.45156097412109"> <GeometryDrawing Geometry="M-2.828,21.042A15.733,9.458,0.000,1,1,-34.295,21.042A15.733,9.458,0.000,1,1,-2.828,21.042z"> <GeometryDrawing.Pen> <Pen Thickness="0.882" StartLineCap="Round" EndLineCap="Round" DashCap="Round" LineJoin="Round" MiterLimit="4"> <Pen.Brush> <LinearGradientBrush StartPoint="-25.176,30.057" EndPoint="-22.114,22.662" MappingMode="Absolute" SpreadMethod="Pad"> <GradientStop Color="White" Offset="0" /> <GradientStop Color="Transparent" Offset="1" /> </LinearGradientBrush> </Pen.Brush> </Pen> </GeometryDrawing.Pen> </GeometryDrawing> </DrawingGroup> <DrawingGroup Transform="-1.04577195644379,0.767251014709473,0.767251014709473,1.04577195644379,35.6165084838867,-22.1439609527588"> <DrawingGroup Transform="1,0,0,1,14.9502601623535,22.9304695129395"> <GeometryDrawing Geometry="M18.789,12.493A6.718,6.718,0.000,1,1,5.354,12.493A6.718,6.718,0.000,1,1,18.789,12.493z"> <GeometryDrawing.Brush> <RadialGradientBrush Center="12.071,12.493" RadiusX="6.718" RadiusY="6.718" GradientOrigin="12.071,12.493" MappingMode="Absolute"> <GradientStop Color="White" Offset="0" /> <GradientStop Color="Transparent" Offset="1" /> </RadialGradientBrush> </GeometryDrawing.Brush> </GeometryDrawing> </DrawingGroup> <DrawingGroup Transform="0.308270990848541,0,0,0.308270990848541,23.300350189209,31.5723400115967"> <GeometryDrawing Brush="{StaticResource Brush2}" Geometry="M18.789,12.493A6.718,6.718,0.000,1,1,5.354,12.493A6.718,6.718,0.000,1,1,18.789,12.493z" /> </DrawingGroup> </DrawingGroup> <DrawingGroup Transform="-1.28031599521637,-0.126158997416496,0.0980622544884682,-0.995180010795593,-2.40512490272522,40.523868560791"> <GeometryDrawing Geometry="M-2.828,21.042A15.733,9.458,0.000,1,1,-34.295,21.042A15.733,9.458,0.000,1,1,-2.828,21.042z"> <GeometryDrawing.Pen> <Pen Thickness="0.882" StartLineCap="Round" EndLineCap="Round" DashCap="Round" LineJoin="Round" MiterLimit="4"> <Pen.Brush> <LinearGradientBrush StartPoint="-22.823,28.338" EndPoint="-22.114,22.662" MappingMode="Absolute" SpreadMethod="Pad"> <GradientStop Color="White" Offset="0" /> <GradientStop Color="Transparent" Offset="1" /> </LinearGradientBrush> </Pen.Brush> </Pen> </GeometryDrawing.Pen> </GeometryDrawing> </DrawingGroup> <DrawingGroup Transform="0.917873978614807,-0.858982980251312,0.667701005935669,0.713433027267456,27.6331691741943,-6.9090690612793"> <GeometryDrawing Geometry="M-2.828,21.042A15.733,9.458,0.000,1,1,-34.295,21.042A15.733,9.458,0.000,1,1,-2.828,21.042z"> <GeometryDrawing.Pen> <Pen Thickness="0.902" StartLineCap="Round" EndLineCap="Round" DashCap="Round" LineJoin="Round" MiterLimit="4"> <Pen.Brush> <LinearGradientBrush StartPoint="-21.659,15.649" EndPoint="-21.962,21.336" MappingMode="Absolute" SpreadMethod="Pad"> <GradientStop Color="White" Offset="0" /> <GradientStop Color="Transparent" Offset="1" /> </LinearGradientBrush> </Pen.Brush> </Pen> </GeometryDrawing.Pen> </GeometryDrawing> </DrawingGroup> <DrawingGroup Transform="-0.806276023387909,0.591539978981018,0.591539978981018,0.806276023387909,12.3856401443481,-18.0292091369629"> <DrawingGroup Transform="1,0,0,1,14.9502601623535,22.9304695129395"> <GeometryDrawing Geometry="M18.789,12.493A6.718,6.718,0.000,1,1,5.354,12.493A6.718,6.718,0.000,1,1,18.789,12.493z"> <GeometryDrawing.Brush> <RadialGradientBrush Center="12.071,12.493" RadiusX="6.718" RadiusY="6.718" GradientOrigin="12.071,12.493" MappingMode="Absolute"> <GradientStop Color="White" Offset="0" /> <GradientStop Color="Transparent" Offset="1" /> </RadialGradientBrush> </GeometryDrawing.Brush> </GeometryDrawing> </DrawingGroup> <DrawingGroup Transform="0.308270990848541,0,0,0.308270990848541,23.300350189209,31.5723400115967"> <GeometryDrawing Brush="{StaticResource Brush2}" Geometry="M18.789,12.493A6.718,6.718,0.000,1,1,5.354,12.493A6.718,6.718,0.000,1,1,18.789,12.493z" /> </DrawingGroup> </DrawingGroup> <DrawingGroup Transform="-0.806276023387909,0.591539978981018,0.591539978981018,0.806276023387909,13.4990997314453,-31.5002193450928"> <DrawingGroup Transform="1,0,0,1,14.9502601623535,22.9304695129395"> <GeometryDrawing Geometry="M18.789,12.493A6.718,6.718,0.000,1,1,5.354,12.493A6.718,6.718,0.000,1,1,18.789,12.493z"> <GeometryDrawing.Brush> <RadialGradientBrush Center="12.071,12.493" RadiusX="6.718" RadiusY="6.718" GradientOrigin="12.071,12.493" MappingMode="Absolute"> <GradientStop Color="White" Offset="0" /> <GradientStop Color="Transparent" Offset="1" /> </RadialGradientBrush> </GeometryDrawing.Brush> </GeometryDrawing> </DrawingGroup> <DrawingGroup Transform="0.308270990848541,0,0,0.308270990848541,23.300350189209,31.5723400115967"> <GeometryDrawing Brush="{StaticResource Brush2}" Geometry="M18.789,12.493A6.718,6.718,0.000,1,1,5.354,12.493A6.718,6.718,0.000,1,1,18.789,12.493z" /> </DrawingGroup> </DrawingGroup> <DrawingGroup Transform="-0.870226979255676,0.638571977615356,0.638458013534546,0.870380997657776,25.2050304412842,-35.3127784729004"> <DrawingGroup Transform="1,0,0,1,14.9502601623535,22.9304695129395"> <GeometryDrawing Geometry="M18.789,12.493A6.718,6.718,0.000,1,1,5.354,12.493A6.718,6.718,0.000,1,1,18.789,12.493z"> <GeometryDrawing.Brush> <RadialGradientBrush Center="12.071,12.493" RadiusX="6.718" RadiusY="6.718" GradientOrigin="12.071,12.493" MappingMode="Absolute"> <GradientStop Color="White" Offset="0" /> <GradientStop Color="Transparent" Offset="1" /> </RadialGradientBrush> </GeometryDrawing.Brush> </GeometryDrawing> </DrawingGroup> <DrawingGroup Transform="0.308270990848541,0,0,0.308270990848541,23.300350189209,31.5723400115967"> <GeometryDrawing Brush="{StaticResource Brush2}" Geometry="M18.789,12.493A6.718,6.718,0.000,1,1,5.354,12.493A6.718,6.718,0.000,1,1,18.789,12.493z" /> </DrawingGroup> </DrawingGroup> </DrawingGroup> </DrawingGroup> </DrawingBrush.Drawing> </DrawingBrush> </ResourceDictionary>
- Canvas:包含一个个实体control感觉整体上更像一个content,使用这个Canvas最好放在一个ViewBox下,可以任意调整大小。
The XAML Canvas format is useful both in WPF and Silverlight applications. A XAML Canvas is a vector format that describes individual elements within the image as individual objects that can be individually accessed and manipulated in your application. It is possible to use objects within a XAML Canvas for animations and other interacitons.
- DrawingBrush:感觉上更像是一个style resources
The XAML Brush is similar to the XAML Canvas, but with the main difference that a Brush is used whenever colors can be used. You can use Brushes to as the background color of a rectangle or the fill color of a font (to name a few examples). In many ways, they are easier to use than canvases, especially in scenarios where the same art is used in multiple places. Note that Brushes only work in WPF but not in Silverlight.(DrawingBrush只能算作是一个style)
总结:如果是Icon的话我prefer用DrawingBrush,一方面Blend里ResourcesTag下可以看到Icon的样子,另一方面可以利用TemplateBinding highjack。
2:使用ContentPresenter还是ContentControl?
- ContentControl的Content部分可以在xaml或者C#定义,xaml里我们写Content = {StaticResource ???} 这里的???可以是任何的key resources(这里是用ViewBox不能是DrawingBrush)
<Viewbox x:Key="NewIconViewBox"> <Canvas x:Name="NewIcon" Width="35" Height="35" HorizontalAlignment="Left" VerticalAlignment="Top" UseLayoutRounding="False"> <Canvas x:Name="Layer_1" Canvas.Left="1.564" Canvas.Top="1.564" Width="31.871" Height="31.872"> <Path Canvas.Left="0" Canvas.Top="0" Width="31.871" Height="31.872" Data="F1M0,15.936C0.001,7.135 7.136,0.002 15.936,0 24.738,0.002 31.872,7.135 31.872,15.936 31.872,24.738 24.738,31.871 15.936,31.872 7.136,31.871 0.001,24.738 0,15.936" Fill="#FF7A7C7F" /> <Path Canvas.Left="0.246" Canvas.Top="0.246" Width="31.381" Height="31.38" Data="F1M0,15.69C0.001,24.356 7.024,31.38 15.69,31.38 24.356,31.38 31.379,24.356 31.381,15.69 31.379,7.024 24.356,0 15.69,0 7.024,0 0.001,7.024 0,15.69"> <Path.Fill> <LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,0"> <GradientStop Offset="0" Color="White" /> <GradientStop Offset="1" Color="#FF221F20" /> </LinearGradientBrush> </Path.Fill> </Path> <Path Canvas.Left="2.264" Canvas.Top="2.141" Width="27.467" Height="27.468" Data="F1M0,13.734C0,21.319 6.149,27.468 13.735,27.468 21.319,27.468 27.467,21.319 27.467,13.734 27.467,6.148 21.319,0 13.735,0 6.149,0 0,6.148 0,13.734"> <Path.Fill> <RadialGradientBrush Center="0.5,0.393" GradientOrigin="0.5,0.393" RadiusX="0.548" RadiusY="0.548"> <GradientStop Offset="0" Color="White" /> <GradientStop Offset="0.61" Color="#FFF7F8F8" /> <GradientStop Offset="0.77" Color="#FFE6E6E7" /> <GradientStop Offset="0.877" Color="#FFCCCCCD" /> <GradientStop Offset="0.96" Color="#FFA5A6A8" /> <GradientStop Offset="1" Color="#FF85878A" /> <GradientStop Offset="1" Color="#FF85878A" /> </RadialGradientBrush> </Path.Fill> </Path> <Path Canvas.Left="0.123" Canvas.Top="12.653" Width="31.627" Height="19.096" Data="F1M0.147,1.13C0.051,1.834 0,2.553 0,3.283 0,12.017 7.08,19.095 15.813,19.096 24.547,19.095 31.626,12.017 31.627,3.283 31.627,2.753 31.6,2.23 31.549,1.715 30.748,1.36 29.961,1.034 29.186,0.735 29.342,1.559 29.424,2.411 29.424,3.283 29.424,7.045 27.903,10.44 25.438,12.907 22.971,15.372 19.576,16.893 15.813,16.893 12.051,16.893 8.656,15.372 6.189,12.907 3.724,10.44 2.203,7.045 2.203,3.283 2.203,2.15 2.342,1.051 2.602,0 1.639,0.385 0.817,0.777 0.147,1.13"> <Path.Fill> <LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,0"> <GradientStop Offset="0" Color="#FFC2C4C6" /> <GradientStop Offset="1" Color="#FF87898C" /> </LinearGradientBrush> </Path.Fill> </Path> <Path Canvas.Left="0.27" Canvas.Top="0.123" Width="31.402" Height="14.245" Data="F1M0,13.66C0.67,13.307 1.492,12.915 2.455,12.53 3.058,10.09 4.319,7.912 6.042,6.189 8.509,3.724 11.904,2.203 15.666,2.202 19.429,2.203 22.824,3.724 25.291,6.189 27.184,8.083 28.519,10.528 29.039,13.265 29.814,13.564 30.601,13.89 31.402,14.245 30.615,6.247 23.871,0 15.666,0 7.663,0 1.051,5.946 0,13.66"> <Path.Fill> <LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,0"> <GradientStop Offset="0" Color="White" /> <GradientStop Offset="1" Color="#FFE6E7E8" /> </LinearGradientBrush> </Path.Fill> </Path> <Path Canvas.Left="2.203" Canvas.Top="2.203" Width="27.467" Height="27.467" Data="F1M4.023,4.022L4.109,4.109 4.023,4.022C1.536,6.51 0,9.937 0,13.733 0,17.528 1.536,20.956 4.023,23.443 6.51,25.931 9.938,27.467 13.733,27.467 17.528,27.467 20.956,25.931 23.444,23.443 25.93,20.956 27.467,17.528 27.467,13.733 27.467,9.937 25.93,6.51 23.444,4.022 20.956,1.536 17.528,0 13.733,0 9.938,0 6.51,1.536 4.023,4.022 M4.196,23.271C1.753,20.825 0.246,17.461 0.244,13.733 0.246,10.005 1.753,6.641 4.196,4.195 6.641,1.753 10.005,0.246 13.733,0.245 17.461,0.246 20.826,1.753 23.272,4.195 25.713,6.641 27.221,10.005 27.221,13.733 27.221,17.461 25.713,20.825 23.272,23.271 20.826,25.713 17.461,27.22 13.733,27.22 10.005,27.22 6.641,25.713 4.196,23.271"> <Path.Fill> <LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,0"> <GradientStop Offset="0" Color="White" /> <GradientStop Offset="0.264" Color="#FFC5C6C6" /> <GradientStop Offset="1" Color="#FF626366" /> </LinearGradientBrush> </Path.Fill> </Path> <Path Canvas.Left="7.527" Canvas.Top="6.492" Width="16.943" Height="18.019" Data="F1M13.132,18.019L10.368,18.019C10.659,17.664 11.421,16.681 11.695,16.277 13.425,13.736 14.763,10.417 14.763,8.471 14.763,5.003 11.941,2.181 8.472,2.181 5.003,2.181 2.18,5.003 2.18,8.471 2.18,10.484 3.459,13.796 5.118,16.28 5.386,16.681 6.152,17.671 6.437,18.019L3.672,18.019C3.224,17.47 3.381,17.63 2.98,16.992 1.235,14.214 0,10.79 0,8.471 0,3.8 3.8,0 8.472,0 13.142,0 16.943,3.8 16.943,8.471 16.943,11.043 15.388,14.654 13.616,17.322 13.261,17.859 13.495,17.577 13.132,18.019" Fill="#FFDA2027" /> <Path Canvas.Left="10.978" Canvas.Top="9.945" Width="10.04" Height="14.641" Data="F1M5.02,1.816C3.252,1.816 1.818,3.253 1.818,5.018 1.818,6.935 3.604,10.433 4.954,12.102 6.354,10.384 8.222,6.851 8.222,5.018 8.222,3.253 6.786,1.816 5.02,1.816 M4.966,14.641L4.36,14.115C2.678,12.652 0.001,7.894 0.001,5.018 0.001,2.252 2.252,0 5.02,0 7.788,0 10.04,2.252 10.04,5.018 10.04,7.771 7.29,12.558 5.564,14.105z" Fill="#FF8F989E" /> </Canvas> </Canvas> </Viewbox>
//使用的时候 <ContentControl Content="{StaticResource NewIconViewBox}" Width="50" Height="50"/>
- ContentPresenter的话一般是在CT或者DT里设置,利用ContentSource="Icon"连接到Icon属性,Icon再连接到一个ViewBox的资源。
3:利用DP来换MouseOverIcon