2010-11-04 16 views
0

我想,有一天我應該嘗試WPF。原來我在第一個障礙中倒下了。 我從Inkscape生成的xaml文件插入代碼,然後將其包裝在Viewbox標籤中。我有錯誤,它不存在於命名空間中。 我在做什麼錯?我需要某種參考嗎?標記'ViewBox'不存在於XML命名空間'http://schemas.microsoft.com/winfx/2006/xaml/presentation'

 <Viewbox Grid.Row="1" Name="viewbox1"> 
     <Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg2816" Width="64px" Height="64px"> 
     <Canvas.Resources> 
      <LinearGradientBrush xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Key="linearGradient3669" MappingMode="RelativeToBoundingBox" StartPoint="0,0" EndPoint="1,1"> 
       <LinearGradientBrush.GradientStops> 
        <GradientStopCollection> 
         <GradientStop Color="#FF275000" Offset="0"/> 
         <GradientStop Color="#FF3B7900" Offset="1"/> 
        </GradientStopCollection> 
       </LinearGradientBrush.GradientStops> 
      </LinearGradientBrush> 
     </Canvas.Resources> 
     <Canvas Name="layer1"> 
      <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path2844048" Fill="#FF3B7900" Data="m 29.183638 53.482324 c 2.179239 -2.07933 3.162867 -5.4475 2.714311 -9.294478 C 31.481751 40.618383 30.410408 37.379681 27.934941 32.207515 24.105679 24.206789 21.991432 16.323367 21.79738 9.3222671 L 21.76509 8.1573925 21.580788 9.2913951 c -0.275401 1.6945879 -0.487645 6.4922019 -0.423266 9.5676099 0.128472 6.13678 1.499426 13.669646 3.418244 18.781945 2.311617 6.158849 2.405775 10.747988 0.316505 15.426227 l -0.279428 0.625809 0.989492 0.580699 c 1.475461 0.865907 1.955666 0.759796 3.58134 -0.791345 z"/> 
      <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path284416" Fill="#FF275000" Data="m 34.9079 62.395737 c 2.978872 -0.505727 5.687028 -2.75405 7.473161 -6.204258 1.657283 -3.201317 2.584232 -6.495325 3.428893 -12.184907 1.306582 -8.80111 3.973232 -16.542158 7.741175 -22.471943 l 0.108761 -0.171162 0.170319 -0.268038 0.347847 -0.547422 -0.789675 0.839401 c -1.180046 1.254348 -4.049114 5.124074 -5.721624 7.717172 -3.337383 5.174357 -6.425278 12.206782 -7.69915 17.534175 -1.534655 6.417972 -4.031971 10.286329 -8.394645 13.003343 l -0.583575 0.363443 0.496775 1.038151 c 0.740754 1.548016 1.199555 1.729304 3.421738 1.352045 z"/> 
      <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path284409" Fill="#FF3B7900" Data="m 27.376935 57.456109 c -1.897221 -3.123581 -1.987094 -7.379979 -0.248 -11.745542 1.613639 -4.050638 3.890496 -7.50709 8.422338 -12.785811 C 42.561502 24.759204 47.52544 16.190058 49.961372 8.0488827 l 0.4053 -1.3545622 -0.141812 1.3867204 c -0.211917 2.0722341 -1.476719 7.7600051 -2.522324 11.3428011 -2.086432 7.149238 -6.06895 15.542157 -9.929744 20.92634 -4.651138 6.486396 -6.209149 11.833264 -5.237195 17.973307 l 0.130007 0.821329 -1.342464 0.368195 C 29.321349 60.06204 28.792225 59.78624 27.37693 57.45611 z"/> 
      <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path2844178" Fill="#FF275000" Data="m 32.361831 61.035235 c 3.493335 -1.550271 6.110584 -5.151941 7.2223 -9.938819 1.031514 -4.441562 1.138889 -8.768635 0.397193 -16.006327 C 38.833998 23.894235 39.684836 13.572942 42.451268 5.1278002 l 0.460291 -1.4051379 -0.705758 1.2755162 c -1.054647 1.9060513 -3.362718 7.5453745 -4.602862 11.2461825 -2.474625 7.384716 -4.063116 16.968998 -3.96064 23.896801 0.123449 8.346009 -1.729383 13.867547 -6.228235 18.560457 l -0.601791 0.62775 0.933155 1.117334 c 1.391455 1.666088 2.010441 1.745002 4.616403 0.588532 z"/> 
      <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path28446" Fill="#FF275000" Data="m 31.254942 62.474518 c -3.60306 -0.611695 -6.87868 -3.33113 -9.039078 -7.504291 C 20.211316 51.098112 19.090136 47.113881 18.068488 40.232113 16.488125 29.586831 13.262709 20.223733 8.7052352 13.05143 L 7.9469434 11.858073 8.902086 12.87336 c 1.427311 1.517184 4.89756 6.197765 6.920524 9.334217 4.036695 6.258585 7.771624 14.764575 9.31242 21.208262 1.856224 7.762786 4.876825 12.441714 10.153647 15.728046 l 0.705857 0.4396 -0.600867 1.255683 c -0.895971 1.872386 -1.45091 2.09166 -4.138725 1.63535 z"/> 
      <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path284404" Fill="#FF3B7900" Data="m 29.113675 53.484094 c 2.179239 -2.07933 3.162867 -5.4475 2.714311 -9.294478 C 31.411788 40.620153 30.340445 37.381451 27.864978 32.209285 24.035716 24.208559 21.921469 16.325137 21.727417 9.3240371 l -0.03229 -1.1648746 -0.184302 1.1340026 c -0.275401 1.6945879 -0.487645 6.4922019 -0.423266 9.5676099 0.128472 6.13678 1.499426 13.669646 3.418244 18.781945 2.311617 6.158849 2.405775 10.747988 0.316505 15.426227 l -0.279428 0.625809 0.989492 0.580699 c 1.475461 0.865907 1.955666 0.759796 3.58134 -0.791345 z"/> 
      <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path28441" Fill="#FF275000" Data="m 34.837937 62.397507 c 2.978872 -0.505727 5.687028 -2.75405 7.473161 -6.204258 1.657283 -3.201317 2.584232 -6.495325 3.428893 -12.184907 1.306582 -8.80111 3.973232 -16.542158 7.741175 -22.471943 l 0.108761 -0.171162 0.170319 -0.268038 0.347847 -0.547422 -0.789675 0.839401 c -1.180046 1.254348 -4.049114 5.124074 -5.721624 7.717172 -3.337383 5.174357 -6.425278 12.206782 -7.69915 17.534175 -1.534655 6.417972 -4.031971 10.286329 -8.394645 13.003343 l -0.583575 0.363443 0.496775 1.038151 c 0.740754 1.548016 1.199555 1.729304 3.421738 1.352045 z"/> 
      <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path28440" Fill="#FF3B7900" Data="m 27.306972 57.457879 c -1.897221 -3.123581 -1.987094 -7.379979 -0.248 -11.745542 1.613639 -4.050638 3.890496 -7.50709 8.422338 -12.785811 7.010229 -8.165552 11.974167 -16.734698 14.410099 -24.8758733 l 0.4053 -1.3545622 -0.141812 1.3867204 c -0.211917 2.0722341 -1.476719 7.7600051 -2.522324 11.3428011 -2.086432 7.149238 -6.06895 15.542157 -9.929744 20.92634 -4.651138 6.486396 -6.209149 11.833264 -5.237195 17.973307 l 0.130007 0.821329 -1.342464 0.368195 c -2.001791 0.549027 -2.530915 0.273227 -3.94621 -2.056903 z"/> 
      <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path284417" Fill="#FF275000" Data="m 32.291868 61.037005 c 3.493335 -1.550271 6.110584 -5.151941 7.2223 -9.938819 1.031514 -4.441562 1.138889 -8.768635 0.397193 -16.006327 C 38.764035 23.896005 39.614873 13.574712 42.381305 5.1295702 l 0.460291 -1.4051379 -0.705758 1.2755162 c -1.054647 1.9060513 -3.362718 7.5453745 -4.602862 11.2461825 -2.474625 7.384716 -4.063116 16.968998 -3.96064 23.896801 0.123449 8.346009 -1.729383 13.867547 -6.228235 18.560457 l -0.601791 0.62775 0.933155 1.117334 c 1.391455 1.666088 2.010441 1.745002 4.616403 0.588532 z"/> 
      <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path2844" Fill="#FF275000" Data="m 31.184979 62.476288 c -3.60306 -0.611695 -6.87868 -3.33113 -9.039078 -7.504291 C 20.141353 51.099882 19.020173 47.115651 17.998525 40.233883 16.418162 29.588601 13.192746 20.225503 8.6352719 13.0532 L 7.8769801 11.859843 8.8321227 12.87513 c 1.4273113 1.517184 4.8975603 6.197765 6.9205243 9.334217 4.036695 6.258585 7.771624 14.764575 9.31242 21.208262 1.856224 7.762786 4.876825 12.441714 10.153647 15.728046 l 0.705857 0.4396 -0.600867 1.255683 c -0.895971 1.872386 -1.45091 2.09166 -4.138725 1.63535 z"/> 
      <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path49098" Fill="#FF161413" Data="m 39.156038 12.64637 a 16.661203 6.0104074 0 1 1 -33.3224065 0 16.661203 6.0104074 0 1 1 33.3224065 0 z"> 
       <!--path--> 
      </Path> 
     </Canvas> 
    </Canvas> 
     </Viewbox> 

回答

1

下面的步驟,我是能夠運行您的樣品:

  • 創建一個新的WPF項目;

  • 在打開的自動創建的窗口中,我刪除了<Grid></Grid>對象;

  • 我將其替換爲您的代碼示例。

這工作成功。以下是結果:

<Window x:Class="WpfApplication2.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MainWindow" Height="350" Width="525"> 
    <Viewbox Grid.Row="1" Name="viewbox1"> 
     <Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg2816" Width="64px" Height="64px"> 
      <Canvas.Resources> 
       <LinearGradientBrush xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Key="linearGradient3669" MappingMode="RelativeToBoundingBox" StartPoint="0,0" EndPoint="1,1"> 
        <LinearGradientBrush.GradientStops> 
         <GradientStopCollection> 
          <GradientStop Color="#FF275000" Offset="0"/> 
          <GradientStop Color="#FF3B7900" Offset="1"/> 
         </GradientStopCollection> 
        </LinearGradientBrush.GradientStops> 
       </LinearGradientBrush> 
      </Canvas.Resources> 
      <Canvas Name="layer1"> 
       <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path2844048" Fill="#FF3B7900" Data="m 29.183638 53.482324 c 2.179239 -2.07933 3.162867 -5.4475 2.714311 -9.294478 C 31.481751 40.618383 30.410408 37.379681 27.934941 32.207515 24.105679 24.206789 21.991432 16.323367 21.79738 9.3222671 L 21.76509 8.1573925 21.580788 9.2913951 c -0.275401 1.6945879 -0.487645 6.4922019 -0.423266 9.5676099 0.128472 6.13678 1.499426 13.669646 3.418244 18.781945 2.311617 6.158849 2.405775 10.747988 0.316505 15.426227 l -0.279428 0.625809 0.989492 0.580699 c 1.475461 0.865907 1.955666 0.759796 3.58134 -0.791345 z"/> 
       <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path284416" Fill="#FF275000" Data="m 34.9079 62.395737 c 2.978872 -0.505727 5.687028 -2.75405 7.473161 -6.204258 1.657283 -3.201317 2.584232 -6.495325 3.428893 -12.184907 1.306582 -8.80111 3.973232 -16.542158 7.741175 -22.471943 l 0.108761 -0.171162 0.170319 -0.268038 0.347847 -0.547422 -0.789675 0.839401 c -1.180046 1.254348 -4.049114 5.124074 -5.721624 7.717172 -3.337383 5.174357 -6.425278 12.206782 -7.69915 17.534175 -1.534655 6.417972 -4.031971 10.286329 -8.394645 13.003343 l -0.583575 0.363443 0.496775 1.038151 c 0.740754 1.548016 1.199555 1.729304 3.421738 1.352045 z"/> 
       <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path284409" Fill="#FF3B7900" Data="m 27.376935 57.456109 c -1.897221 -3.123581 -1.987094 -7.379979 -0.248 -11.745542 1.613639 -4.050638 3.890496 -7.50709 8.422338 -12.785811 C 42.561502 24.759204 47.52544 16.190058 49.961372 8.0488827 l 0.4053 -1.3545622 -0.141812 1.3867204 c -0.211917 2.0722341 -1.476719 7.7600051 -2.522324 11.3428011 -2.086432 7.149238 -6.06895 15.542157 -9.929744 20.92634 -4.651138 6.486396 -6.209149 11.833264 -5.237195 17.973307 l 0.130007 0.821329 -1.342464 0.368195 C 29.321349 60.06204 28.792225 59.78624 27.37693 57.45611 z"/> 
       <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path2844178" Fill="#FF275000" Data="m 32.361831 61.035235 c 3.493335 -1.550271 6.110584 -5.151941 7.2223 -9.938819 1.031514 -4.441562 1.138889 -8.768635 0.397193 -16.006327 C 38.833998 23.894235 39.684836 13.572942 42.451268 5.1278002 l 0.460291 -1.4051379 -0.705758 1.2755162 c -1.054647 1.9060513 -3.362718 7.5453745 -4.602862 11.2461825 -2.474625 7.384716 -4.063116 16.968998 -3.96064 23.896801 0.123449 8.346009 -1.729383 13.867547 -6.228235 18.560457 l -0.601791 0.62775 0.933155 1.117334 c 1.391455 1.666088 2.010441 1.745002 4.616403 0.588532 z"/> 
       <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path28446" Fill="#FF275000" Data="m 31.254942 62.474518 c -3.60306 -0.611695 -6.87868 -3.33113 -9.039078 -7.504291 C 20.211316 51.098112 19.090136 47.113881 18.068488 40.232113 16.488125 29.586831 13.262709 20.223733 8.7052352 13.05143 L 7.9469434 11.858073 8.902086 12.87336 c 1.427311 1.517184 4.89756 6.197765 6.920524 9.334217 4.036695 6.258585 7.771624 14.764575 9.31242 21.208262 1.856224 7.762786 4.876825 12.441714 10.153647 15.728046 l 0.705857 0.4396 -0.600867 1.255683 c -0.895971 1.872386 -1.45091 2.09166 -4.138725 1.63535 z"/> 
       <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path284404" Fill="#FF3B7900" Data="m 29.113675 53.484094 c 2.179239 -2.07933 3.162867 -5.4475 2.714311 -9.294478 C 31.411788 40.620153 30.340445 37.381451 27.864978 32.209285 24.035716 24.208559 21.921469 16.325137 21.727417 9.3240371 l -0.03229 -1.1648746 -0.184302 1.1340026 c -0.275401 1.6945879 -0.487645 6.4922019 -0.423266 9.5676099 0.128472 6.13678 1.499426 13.669646 3.418244 18.781945 2.311617 6.158849 2.405775 10.747988 0.316505 15.426227 l -0.279428 0.625809 0.989492 0.580699 c 1.475461 0.865907 1.955666 0.759796 3.58134 -0.791345 z"/> 
       <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path28441" Fill="#FF275000" Data="m 34.837937 62.397507 c 2.978872 -0.505727 5.687028 -2.75405 7.473161 -6.204258 1.657283 -3.201317 2.584232 -6.495325 3.428893 -12.184907 1.306582 -8.80111 3.973232 -16.542158 7.741175 -22.471943 l 0.108761 -0.171162 0.170319 -0.268038 0.347847 -0.547422 -0.789675 0.839401 c -1.180046 1.254348 -4.049114 5.124074 -5.721624 7.717172 -3.337383 5.174357 -6.425278 12.206782 -7.69915 17.534175 -1.534655 6.417972 -4.031971 10.286329 -8.394645 13.003343 l -0.583575 0.363443 0.496775 1.038151 c 0.740754 1.548016 1.199555 1.729304 3.421738 1.352045 z"/> 
       <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path28440" Fill="#FF3B7900" Data="m 27.306972 57.457879 c -1.897221 -3.123581 -1.987094 -7.379979 -0.248 -11.745542 1.613639 -4.050638 3.890496 -7.50709 8.422338 -12.785811 7.010229 -8.165552 11.974167 -16.734698 14.410099 -24.8758733 l 0.4053 -1.3545622 -0.141812 1.3867204 c -0.211917 2.0722341 -1.476719 7.7600051 -2.522324 11.3428011 -2.086432 7.149238 -6.06895 15.542157 -9.929744 20.92634 -4.651138 6.486396 -6.209149 11.833264 -5.237195 17.973307 l 0.130007 0.821329 -1.342464 0.368195 c -2.001791 0.549027 -2.530915 0.273227 -3.94621 -2.056903 z"/> 
       <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path284417" Fill="#FF275000" Data="m 32.291868 61.037005 c 3.493335 -1.550271 6.110584 -5.151941 7.2223 -9.938819 1.031514 -4.441562 1.138889 -8.768635 0.397193 -16.006327 C 38.764035 23.896005 39.614873 13.574712 42.381305 5.1295702 l 0.460291 -1.4051379 -0.705758 1.2755162 c -1.054647 1.9060513 -3.362718 7.5453745 -4.602862 11.2461825 -2.474625 7.384716 -4.063116 16.968998 -3.96064 23.896801 0.123449 8.346009 -1.729383 13.867547 -6.228235 18.560457 l -0.601791 0.62775 0.933155 1.117334 c 1.391455 1.666088 2.010441 1.745002 4.616403 0.588532 z"/> 
       <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path2844" Fill="#FF275000" Data="m 31.184979 62.476288 c -3.60306 -0.611695 -6.87868 -3.33113 -9.039078 -7.504291 C 20.141353 51.099882 19.020173 47.115651 17.998525 40.233883 16.418162 29.588601 13.192746 20.225503 8.6352719 13.0532 L 7.8769801 11.859843 8.8321227 12.87513 c 1.4273113 1.517184 4.8975603 6.197765 6.9205243 9.334217 4.036695 6.258585 7.771624 14.764575 9.31242 21.208262 1.856224 7.762786 4.876825 12.441714 10.153647 15.728046 l 0.705857 0.4396 -0.600867 1.255683 c -0.895971 1.872386 -1.45091 2.09166 -4.138725 1.63535 z"/> 
       <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path49098" Fill="#FF161413" Data="m 39.156038 12.64637 a 16.661203 6.0104074 0 1 1 -33.3224065 0 16.661203 6.0104074 0 1 1 33.3224065 0 z"> 
        <!--path--> 
       </Path> 
      </Canvas> 
     </Canvas> 
    </Viewbox> 
</Window> 
+0

Thnaks!這樣可行! – Qrt 2010-11-07 11:23:17

+0

不客氣。 – 2010-11-07 12:07:28

相關問題