UWP 如何在鼠标悬停时更改路径的填充
UWP How to change the fill of a path when mouse over
我有一张国家地图,由路径组成的州划分。当指针悬停在每个路径上时,我需要更改每个路径的填充颜色。每个 "state" 都有一个单独的 x:Name。我已经尝试通过 C# 这样做:
XAML
<!-- Layer 1/MxBCN -->
<Path StrokeThickness="0.5" x:Name="MxBCN" Stroke="#ffd7d7d7" PointerEntered="Map_PointerEntered" StrokeMiterLimit="1.0" Fill="#ffffffff" Data="F1 M 89.293,6.893 L 88.493,7.393 L 87.993,6.993 L 86.693,6.993 C 86.526,7.495 86.155,9.255 85.593,9.493 L 85.493,10.793 L 83.693,13.193 L 85.093,15.193 L 84.493,16.993 C 85.165,18.247 84.080,20.512 84.593,21.793 L 83.993,22.793 L 84.993,23.793 L 85.893,23.893 L 89.693,26.693 L 89.693,26.693 L 89.193,28.393 L 90.093,32.393 C 88.320,34.101 88.144,37.499 88.194,39.793 C 88.193,39.793 87.293,42.993 87.293,42.993 L 87.593,43.693 L 87.293,45.893 L 87.893,48.093 L 89.293,49.393 L 88.893,49.993 L 88.893,50.693 L 91.693,52.493 C 92.298,54.522 92.336,59.073 92.193,61.193 C 92.193,61.193 93.893,65.193 93.893,65.193 C 93.928,66.029 93.908,67.911 93.593,68.693 C 93.977,69.258 93.447,70.816 93.293,71.393 L 93.693,71.693 L 92.993,73.893 L 93.993,75.993 L 94.593,76.393 L 96.293,80.393 L 97.493,80.993 L 97.793,81.893 L 98.793,82.093 L 99.393,82.993 C 99.359,83.657 99.343,85.143 99.793,85.693 L 100.593,85.993 L 100.993,86.693 L 102.193,86.793 L 102.493,85.893 L 104.293,86.693 L 105.493,88.193 L 105.793,88.093 L 106.793,89.293 C 107.462,89.499 108.102,90.290 108.393,90.893 L 109.993,91.693 C 110.716,92.560 112.459,94.492 113.593,94.793 L 113.693,95.393 L 115.093,96.093 C 115.800,97.036 117.510,99.154 118.493,99.793 L 118.793,100.693 L 118.093,101.493 L 118.093,101.993 C 118.860,102.887 120.639,105.071 120.993,106.193 L 120.393,107.393 L 120.793,108.993 L 120.493,109.293 L 121.293,110.993 L 122.093,111.093 L 122.593,110.393 L 122.193,109.993 L 122.593,109.393 L 123.093,109.693 L 123.593,109.293 L 123.993,110.093 L 124.593,109.993 L 124.593,110.393 L 124.993,110.493 C 125.009,111.179 125.034,112.932 125.493,113.493 L 126.593,113.493 L 127.893,112.493 L 128.993,113.093 C 129.306,113.899 130.248,118.065 131.193,118.393 L 131.793,121.893 L 134.393,123.393 L 136.793,122.793 L 137.293,123.193 L 137.393,123.893 L 138.193,123.693 L 138.293,124.293 L 137.893,124.793 L 138.193,125.493 L 137.593,128.093 L 139.593,130.893 L 139.093,132.893 L 139.693,134.293 L 139.293,135.493 L 140.193,136.093 C 140.653,136.755 140.288,138.857 140.193,139.593 L 140.193,139.593 L 139.593,137.893 L 138.693,137.593 L 106.993,137.493 L 107.193,136.993 C 106.844,136.697 106.817,135.603 106.793,135.193 L 107.693,136.393 L 108.493,134.993 L 106.893,134.593 L 106.593,132.893 L 108.093,129.893 L 107.693,128.893 L 106.793,129.393 L 106.293,128.893 C 107.103,127.459 108.082,124.425 108.293,122.793 L 106.993,120.593 L 105.393,119.993 L 105.293,117.993 L 104.893,117.593 L 102.693,117.493 L 102.693,116.693 C 102.517,116.238 101.187,115.532 100.793,115.293 L 100.893,114.693 L 100.393,113.493 L 99.493,112.993 L 98.893,111.093 L 98.393,110.993 L 98.193,110.393 C 97.711,109.955 96.866,109.524 96.193,109.593 L 95.993,109.893 L 95.493,108.793 L 94.793,108.393 L 94.593,108.693 C 94.451,107.832 94.101,105.557 93.493,104.893 L 92.393,104.393 L 91.793,104.693 C 91.228,104.183 90.753,103.146 90.693,102.393 L 89.493,101.793 L 89.393,101.393 L 88.993,101.393 C 86.156,97.706 84.661,95.507 79.593,95.293 L 77.993,92.793 C 77.441,92.545 75.426,91.328 74.793,91.593 L 72.793,89.693 L 71.593,89.993 L 69.593,87.793 L 69.093,88.293 L 67.193,86.693 C 67.630,84.467 67.544,82.875 65.993,81.093 L 64.393,80.493 L 64.993,76.893 C 64.283,76.139 64.520,72.445 64.493,71.493 C 64.493,71.493 63.093,68.993 63.093,68.993 L 60.993,67.793 L 61.193,66.393 L 60.393,65.593 L 60.193,65.993 L 60.693,66.893 L 60.193,67.193 L 59.693,66.493 L 59.193,66.493 L 59.793,67.793 L 59.393,67.993 L 58.393,65.993 C 58.768,63.342 59.403,58.605 57.893,56.193 C 57.298,56.241 56.183,55.049 55.793,54.693 L 55.293,54.693 L 52.993,51.693 L 51.493,51.893 L 51.093,51.393 L 51.793,46.093 C 51.225,44.590 49.529,42.216 48.293,41.193 C 47.742,40.192 46.333,37.535 45.193,37.093 L 44.493,37.193 L 44.293,36.193 C 43.853,35.889 42.843,35.192 42.793,34.593 L 42.393,34.693 L 42.293,34.093 L 43.293,33.593 L 42.893,32.693 L 43.393,31.493 L 42.193,29.893 L 41.893,29.993 L 41.093,28.993 L 41.593,28.893 L 43.193,29.793 L 44.193,28.793 L 44.393,26.193 L 43.993,25.593 L 42.693,25.293 L 42.093,24.593 L 40.893,24.393 L 40.493,22.593 L 39.993,22.193 L 38.793,22.193 L 37.593,20.993 C 37.628,19.086 37.350,15.990 36.193,14.393 C 35.648,14.158 33.802,13.649 33.593,12.993 C 33.325,12.066 31.085,6.704 31.493,5.793 L 91.693,0.293 L 90.093,3.093 L 89.393,3.293 L 89.893,5.093 L 89.593,5.293 L 89.293,6.893 L 89.293,6.893 Z M 99.193,79.893 L 99.793,80.693 L 99.393,80.793 L 99.093,80.493 L 99.193,79.893 Z M 120.793,92.393 L 120.793,92.893 L 121.893,92.393 L 121.893,92.693 L 122.793,92.993 C 123.190,93.494 124.207,94.886 124.893,94.993 L 125.993,97.193 L 125.393,98.093 L 125.493,99.293 L 127.293,100.093 L 130.193,99.893 L 130.493,100.193 C 130.422,101.481 130.077,105.082 130.893,106.193 L 132.093,106.593 L 131.793,108.493 L 128.793,106.393 L 127.093,103.993 L 124.493,102.193 L 123.493,100.293 L 122.093,99.993 C 122.246,98.507 119.698,96.918 119.693,95.493 L 120.493,93.593 L 120.293,92.593 L 120.793,92.393 Z M 2.993,102.693 L 2.393,103.993 L 2.593,104.993 L 3.893,106.193 L 4.093,109.093 L 3.393,111.193 L 2.593,111.393 L 1.993,109.993 L 2.193,109.093 L 1.593,108.693 L 1.493,107.093 L 0.293,105.893 L 0.693,104.893 L 0.393,103.893 L 1.093,103.293 L 1.893,103.293 C 1.993,103.393 2.993,102.693 2.993,102.693 Z M 145.793,115.793 L 146.093,116.393 L 145.793,117.393 L 144.593,117.393 L 144.193,115.793 L 145.793,115.793 Z M 137.393,117.293 C 138.080,117.140 140.402,119.428 140.893,119.793 L 140.393,120.293 L 139.793,119.293 L 138.093,118.393 L 137.393,117.293 Z M 79.193,125.893 L 79.793,126.293 L 80.593,129.193 C 80.112,129.863 80.563,131.862 80.693,132.593 L 79.993,133.493 L 79.993,135.593 L 79.393,135.393 L 78.893,135.693 L 78.193,135.393 L 77.593,133.993 L 76.993,133.793 L 75.993,134.393 L 75.593,134.293 L 75.693,133.493 C 76.023,133.061 78.738,130.383 78.593,129.793 L 77.993,128.193 L 78.493,126.293 L 79.193,125.893 Z M 106.593,137.893 L 105.893,137.893 L 105.093,137.993 L 105.193,138.393 C 104.838,138.630 104.126,138.891 103.693,138.793 L 102.893,139.693 L 102.593,138.993 C 102.362,138.364 105.575,134.876 105.893,134.393 L 106.493,134.293 L 106.593,135.293 L 105.793,136.093 L 105.793,136.593 L 106.593,137.893 Z"/>
<!-- Layer 1/MxBCS -->
<Path StrokeThickness="0.5" x:Name="MxBCS" Stroke="#ffd7d7d7" PointerEntered="Map_PointerEntered" StrokeMiterLimit="1.0" Fill="#ffffffff" Data="F1 M 105.893,137.893 L 106.593,137.893 L 106.993,138.293 L 107.293,137.893 L 138.993,137.993 L 139.893,138.293 L 140.493,139.993 L 140.493,139.993 L 140.393,140.493 L 141.693,141.493 L 142.093,143.493 L 143.193,144.793 L 143.593,144.793 L 144.793,146.493 L 147.593,147.393 L 148.093,147.993 C 149.298,147.942 150.737,149.201 151.293,150.193 C 151.293,150.193 151.993,153.893 151.993,153.893 C 152.944,154.724 154.218,156.688 154.593,157.893 L 154.193,158.693 L 156.793,160.793 L 159.293,161.393 L 159.793,161.993 L 160.693,161.993 L 160.793,162.693 L 160.193,162.693 L 159.293,163.693 L 159.093,165.293 C 159.547,165.908 160.851,168.065 161.693,168.193 L 161.693,168.693 L 162.593,169.393 L 162.893,170.793 C 162.313,171.068 161.854,172.117 161.693,172.693 L 162.893,173.393 L 163.193,174.593 L 164.293,175.293 L 164.993,176.993 L 165.993,177.793 L 167.593,176.393 L 164.193,172.793 C 164.182,171.662 163.983,169.238 163.293,168.293 L 163.993,167.793 C 164.723,168.278 166.300,169.425 166.593,170.293 C 167.144,170.602 168.302,171.341 168.493,171.993 C 168.493,171.993 170.693,173.393 170.693,173.393 L 170.493,176.893 L 170.893,177.493 L 173.593,178.393 C 173.275,179.060 172.841,180.447 172.993,181.193 L 174.093,183.093 L 174.793,183.393 C 175.003,183.699 175.070,184.630 175.093,184.993 L 174.693,185.693 L 176.693,190.893 L 176.093,191.793 L 176.193,193.193 L 175.693,193.893 C 175.688,194.350 175.835,195.168 176.193,195.493 L 176.293,197.393 L 176.893,198.093 L 176.893,199.193 L 178.693,200.693 L 178.893,200.493 L 179.693,203.593 L 181.493,205.993 L 184.093,206.293 L 183.893,207.893 L 185.093,210.993 L 185.993,211.893 L 186.293,212.993 L 185.993,213.193 C 186.111,213.820 186.485,215.064 186.993,215.493 L 186.993,216.493 L 187.693,216.993 L 188.093,218.293 L 188.993,218.793 L 189.493,219.693 L 189.993,219.593 L 190.793,220.193 C 190.738,221.168 192.132,222.974 192.694,223.693 C 192.693,223.693 193.393,225.793 193.393,225.793 C 193.252,227.074 192.686,228.902 191.593,229.693 C 191.489,231.782 190.914,233.569 192.693,235.193 L 192.793,238.093 C 193.486,238.655 194.342,240.042 194.593,240.893 C 194.593,240.893 196.093,242.293 196.093,242.293 C 196.984,242.454 200.750,243.428 201.593,243.093 L 201.693,243.393 L 200.393,243.893 L 199.593,243.293 L 199.193,243.593 L 199.393,245.093 L 201.093,244.993 L 201.093,244.193 L 202.293,243.193 C 202.647,242.457 201.771,240.656 201.493,239.993 L 201.793,238.893 L 202.493,238.493 L 204.093,238.693 L 204.093,239.493 L 205.193,240.093 L 205.593,241.193 C 206.781,241.614 208.853,242.954 209.793,243.793 L 210.493,246.993 L 211.693,247.293 L 214.293,246.393 L 214.293,246.993 L 214.793,247.493 L 214.093,248.393 L 214.193,250.393 L 217.393,253.593 C 217.178,254.759 216.849,256.858 217.793,257.793 C 217.793,257.793 223.193,260.393 223.193,260.393 L 222.893,261.193 L 224.293,263.293 L 224.093,263.993 L 224.493,264.393 L 223.993,268.793 C 223.460,270.224 221.812,272.306 220.493,273.093 C 219.591,273.226 217.748,273.709 217.093,274.393 L 217.093,275.193 L 214.993,276.293 C 214.816,276.890 214.140,277.698 213.593,277.993 L 212.693,277.993 L 212.093,278.693 L 210.993,278.693 C 207.009,276.499 206.851,270.650 205.893,266.792 C 205.893,266.793 203.393,262.193 203.393,262.193 L 201.593,259.793 L 195.393,256.493 L 183.793,244.993 C 183.793,244.993 172.993,238.493 172.993,238.493 L 173.093,238.193 C 172.514,237.417 170.973,236.380 170.093,235.993 L 170.193,235.493 L 169.593,235.393 L 168.593,232.393 L 168.893,232.293 L 168.393,231.693 L 167.393,231.393 L 167.293,232.493 L 164.893,232.293 L 164.793,233.093 L 164.193,233.093 C 164.734,230.677 162.953,228.733 161.393,227.193 L 161.693,226.893 L 161.093,226.393 L 160.393,226.693 L 160.493,227.093 C 159.562,227.248 157.867,226.453 157.093,225.993 L 156.793,225.293 L 157.293,225.293 L 157.393,224.493 L 156.793,224.093 L 156.593,223.293 L 157.193,222.293 L 156.893,222.093 L 157.293,221.393 L 156.893,221.293 L 157.093,220.893 L 156.693,220.393 L 156.093,221.293 L 156.393,222.093 L 155.993,222.593 L 156.093,225.093 L 155.393,225.093 L 154.893,223.993 L 155.693,222.393 L 155.093,220.993 L 155.893,220.593 C 156.179,219.984 156.774,218.581 156.593,217.893 L 155.693,217.993 L 155.893,216.093 C 156.394,215.197 157.060,213.323 157.093,212.293 L 157.793,212.193 L 157.893,209.793 L 157.393,209.693 L 157.493,208.493 L 158.093,208.093 L 157.693,207.793 C 157.492,207.229 157.513,206.228 157.793,205.693 L 158.093,205.593 C 158.143,204.747 158.230,202.711 158.093,201.893 L 157.293,200.793 C 157.466,198.846 155.716,194.287 154.993,192.493 C 154.579,191.581 153.062,190.600 152.193,190.193 L 151.293,187.293 L 149.693,185.393 L 148.093,184.993 L 147.893,185.693 L 147.493,185.793 C 147.026,185.478 144.100,183.248 143.593,183.193 L 142.893,183.493 C 142.556,182.571 140.893,181.383 140.093,180.893 L 140.093,180.493 L 139.493,180.493 L 135.893,177.493 C 136.622,177.374 137.667,178.061 138.193,178.493 L 138.293,178.293 C 137.810,177.847 136.758,177.253 136.093,177.193 L 135.393,177.393 L 133.093,175.393 L 133.293,175.193 L 132.893,174.693 L 133.293,174.093 C 132.430,173.192 131.049,171.195 130.693,169.993 L 130.293,171.093 L 128.793,170.393 L 129.093,170.093 L 129.593,170.293 C 130.351,169.600 131.508,168.509 131.593,167.393 L 130.793,164.593 L 130.193,165.193 L 129.793,168.393 L 129.193,168.893 L 128.493,168.693 C 127.989,169.189 128.136,170.670 128.193,171.293 L 127.793,171.393 C 126.993,170.821 125.213,169.770 124.193,169.793 L 124.393,169.293 L 124.893,169.693 L 124.993,169.293 C 124.661,168.975 123.483,169.242 123.093,169.293 C 122.570,169.712 122.007,170.735 121.893,171.393 L 121.293,171.693 L 121.293,172.293 L 120.593,172.693 C 120.153,172.575 119.360,172.164 118.993,171.893 L 118.293,170.493 L 116.693,170.093 L 115.093,166.393 L 113.293,165.093 L 111.093,164.493 L 110.693,164.693 L 110.493,165.293 L 110.093,165.293 C 109.240,164.662 108.115,162.956 107.694,161.993 C 106.632,160.997 104.837,160.342 103.393,160.293 L 102.593,160.993 L 100.193,159.393 L 99.693,159.793 L 99.193,159.493 L 99.293,158.693 L 98.693,158.293 L 98.193,158.393 C 97.863,158.320 98.027,154.751 97.993,154.493 C 97.993,154.493 97.493,152.893 97.493,152.893 L 95.193,150.993 L 91.893,149.793 L 90.693,147.493 L 88.993,146.193 L 88.893,145.193 L 88.193,144.693 L 87.593,145.593 L 86.793,145.193 L 86.493,144.293 L 85.493,143.793 L 84.893,144.093 C 84.585,143.324 83.800,140.892 82.993,140.493 L 83.793,140.093 L 84.893,140.993 C 85.815,140.866 87.795,140.742 88.693,140.993 L 89.093,141.493 C 89.859,141.257 91.335,141.359 92.093,141.593 L 92.593,142.093 C 93.579,142.467 95.958,142.312 96.993,142.193 L 97.593,142.593 L 99.993,141.293 L 100.593,141.693 L 101.393,141.593 L 101.593,140.993 L 100.993,140.993 L 102.093,139.793 L 102.993,140.093 L 102.493,142.593 C 102.825,143.438 104.043,144.610 104.794,145.093 C 105.736,145.198 106.787,146.016 107.393,146.693 L 107.293,147.093 L 108.093,147.393 L 109.093,146.293 L 109.193,145.393 L 111.293,146.093 L 112.893,149.093 L 113.793,149.193 L 114.393,147.993 L 112.793,146.393 L 112.893,145.293 L 113.593,145.893 L 113.793,145.493 L 113.193,145.093 L 113.493,144.493 C 113.285,143.886 112.832,142.508 113.193,141.893 L 111.393,140.493 L 110.393,142.393 L 110.593,143.493 L 107.393,144.693 L 105.793,143.493 L 105.993,142.993 L 106.593,143.493 L 105.893,141.493 L 107.093,139.793 C 106.658,139.535 106.103,138.333 105.893,137.893 L 105.893,137.893 Z M 79.193,139.393 L 80.593,140.193 L 80.493,140.693 L 79.093,139.693 L 79.193,139.393 Z M 162.593,151.793 L 162.993,151.893 L 163.293,152.493 L 162.393,152.493 L 162.193,151.993 L 162.593,151.793 Z M 157.493,157.293 L 158.593,158.293 L 158.293,159.493 L 157.693,159.293 L 157.093,157.993 L 157.493,157.293 Z M 128.893,172.093 L 130.193,172.393 L 130.993,173.993 C 130.423,173.468 128.735,173.042 127.993,172.893 L 127.893,172.593 L 128.893,172.093 Z M 177.993,188.593 L 178.193,189.393 L 177.793,189.493 L 177.593,188.993 L 177.993,188.593 Z M 183.193,190.493 L 182.693,191.493 L 183.093,193.193 L 181.893,192.493 L 180.193,195.193 L 180.193,196.093 L 179.593,196.693 L 179.593,197.393 L 178.993,197.493 L 178.893,196.693 L 179.293,196.293 L 179.493,194.593 L 180.593,192.893 L 180.393,191.393 L 181.393,191.093 L 181.593,190.693 L 182.193,191.093 L 183.193,190.493 L 183.193,190.493 Z M 183.893,200.293 L 184.393,201.593 L 184.093,202.093 L 183.693,201.893 L 183.293,200.493 L 183.893,200.293 Z M 190.393,200.293 L 190.693,203.593 L 189.993,203.193 L 189.593,201.793 L 190.393,200.293 Z M 157.393,201.293 C 157.609,202.430 157.557,204.745 157.393,205.893 L 157.093,205.893 L 157.393,201.293 L 157.393,201.293 Z M 157.293,206.493 C 157.235,207.561 157.199,211.367 156.693,212.293 L 156.193,211.893 L 157.293,206.493 L 157.293,206.493 Z M 192.493,211.393 L 192.093,212.593 L 191.593,212.793 L 191.493,212.093 L 192.493,211.393 Z M 156.493,212.493 C 157.027,213.497 155.905,216.325 155.593,217.293 C 155.593,217.293 155.693,220.393 155.693,220.393 L 154.893,221.093 L 155.593,222.393 L 155.293,223.493 L 154.693,223.593 L 154.393,224.093 C 154.372,224.655 155.356,225.704 155.693,226.093 L 155.493,226.393 L 156.393,227.193 L 156.793,228.493 L 156.093,229.593 C 156.754,230.013 157.856,231.544 158.293,232.193 L 158.193,232.593 L 157.093,232.093 L 156.993,231.393 L 155.193,229.493 L 155.393,228.993 L 155.993,229.093 C 156.259,228.774 156.140,227.864 156.093,227.493 C 155.741,226.832 154.682,226.053 153.993,225.793 L 152.793,226.193 L 152.093,225.793 L 152.093,225.193 L 152.493,225.093 C 153.719,222.162 155.681,215.604 156.493,212.493 L 156.493,212.493 Z M 192.093,217.093 L 192.993,218.493 L 194.993,218.993 C 195.455,219.340 195.475,220.586 195.493,221.093 C 195.493,221.093 196.493,223.293 196.493,223.293 L 195.993,223.393 L 193.393,221.393 C 193.163,220.560 192.589,218.963 191.793,218.493 L 192.093,217.093 Z M 199.893,231.193 L 200.793,232.493 L 200.193,232.793 L 199.593,232.393 L 199.493,231.593 L 199.893,231.193 Z M 200.793,232.793 L 202.593,234.393 L 201.693,236.393 L 201.193,236.393 L 201.193,235.593 L 200.493,235.293 L 200.593,234.793 L 200.093,234.193 L 200.293,233.493 L 199.993,232.993 L 200.793,232.793 Z M 159.993,232.993 L 163.093,233.193 L 164.193,234.593 L 165.093,234.693 C 165.862,234.927 166.841,237.059 167.193,237.693 L 166.793,238.493 L 159.893,233.493 L 159.593,233.193 L 159.993,232.993 Z M 211.493,237.093 C 212.222,238.312 214.814,242.114 214.693,243.593 L 213.093,243.293 C 212.211,242.089 211.011,238.573 211.493,237.093 L 211.493,237.093 Z M 91.193,397.593 L 92.693,397.993 C 92.422,398.425 91.340,398.539 90.893,398.593 L 90.793,397.893 C 90.693,397.793 91.193,397.593 91.193,397.593 Z"/>
<!-- Layer 1/MxCAM -->
<Path StrokeThickness="0.5" x:Name="MxCAM" Stroke="#ffd7d7d7" PointerEntered="Map_PointerEntered" StrokeMiterLimit="1.0" Fill="#ffffffff" Data="F1 M 700.793,333.493 L 700.593,340.793 L 704.693,341.293 L 705.693,343.293 L 706.193,343.493 L 707.293,343.093 L 708.193,344.093 L 708.693,343.993 C 708.815,343.410 709.382,342.599 709.893,342.293 C 710.295,342.380 711.096,344.080 711.293,344.393 L 711.193,345.293 C 711.409,346.118 712.916,347.089 713.593,347.493 L 715.593,351.993 L 719.493,354.093 C 719.952,355.847 722.649,358.917 723.894,360.193 C 724.029,360.632 724.610,363.904 725.093,364.093 L 725.093,364.093 C 725.668,365.590 730.463,369.171 731.694,370.193 C 731.693,370.193 735.093,374.893 735.093,374.893 L 734.893,380.793 C 734.402,381.036 733.426,381.601 733.293,382.193 C 733.954,384.530 732.385,388.784 732.893,391.093 C 733.230,391.477 734.102,392.441 734.093,392.993 L 733.593,394.393 L 734.393,394.893 L 733.793,396.593 C 734.426,397.474 734.507,401.623 734.593,402.693 C 734.397,403.710 732.255,406.021 731.593,406.793 L 731.893,409.293 L 731.893,409.293 L 731.893,412.593 L 685.993,412.593 L 685.993,412.593 L 685.993,410.993 L 681.993,409.393 L 681.293,409.793 C 680.919,409.091 679.613,408.429 678.893,408.193 C 678.893,408.193 677.293,406.693 677.293,406.693 C 675.706,406.231 672.430,405.698 670.793,405.993 C 670.437,406.755 670.580,408.307 670.793,409.093 L 670.493,409.793 C 669.667,409.742 668.182,410.010 667.493,410.493 L 665.293,409.393 L 663.793,409.493 L 662.493,408.793 L 661.593,407.393 C 658.332,405.494 657.042,404.354 655.793,400.693 L 655.293,400.393 L 655.493,398.393 C 655.268,398.137 654.373,396.809 653.993,396.793 L 653.893,397.193 L 653.393,397.293 L 652.693,396.193 L 651.693,396.193 C 649.456,395.149 649.249,392.621 648.593,390.593 L 648.593,390.593 C 650.628,389.902 659.232,389.543 661.493,389.393 L 662.393,390.793 L 663.893,391.593 L 663.293,392.793 L 662.993,392.393 L 662.694,392.693 L 661.694,391.393 L 660.993,392.293 L 660.293,391.893 L 660.093,392.093 L 660.293,392.793 L 659.793,393.393 L 660.393,394.093 L 661.593,393.793 L 661.093,392.693 L 661.893,392.693 L 662.193,393.193 L 662.793,393.093 L 663.893,393.793 L 664.093,394.393 C 665.124,394.587 671.362,396.478 672.293,395.993 C 672.182,394.237 676.657,393.638 677.693,393.093 L 678.493,390.193 L 679.093,389.893 C 679.232,389.411 679.498,388.355 679.193,387.893 L 678.093,386.893 L 677.193,387.593 L 675.993,386.993 L 675.693,385.993 L 676.293,385.493 L 676.193,384.693 L 677.193,383.693 L 676.393,383.893 C 676.138,384.490 675.471,385.561 674.893,385.893 L 674.393,385.893 L 673.593,386.693 L 673.493,387.293 L 672.893,387.293 L 672.893,387.093 L 675.393,384.493 L 682.193,380.793 C 685.066,378.688 690.438,374.921 692.393,371.893 C 692.146,371.224 692.608,369.548 692.794,368.893 C 692.793,368.893 692.593,366.693 692.593,366.693 L 693.293,364.893 L 692.793,364.293 L 692.793,363.693 C 693.266,363.224 693.919,362.296 693.894,361.593 L 697.694,358.693 L 699.094,356.193 L 698.094,353.493 L 698.394,352.093 L 697.993,350.793 L 698.394,350.493 C 698.394,349.824 697.730,345.678 698.294,345.193 C 698.293,345.193 697.793,341.793 697.793,341.793 L 699.093,338.193 L 699.493,335.193 L 700.793,333.493 L 700.793,333.493 Z M 672.093,386.893 L 672.593,387.693 C 672.340,387.935 671.750,388.433 671.393,388.493 L 670.293,387.893 L 669.893,388.193 L 670.293,388.493 L 668.593,389.793 L 668.093,389.093 L 667.793,389.693 C 667.105,390.009 665.367,390.803 664.593,390.693 L 664.093,390.093 L 664.393,389.793 C 666.114,389.909 670.567,387.630 672.093,386.893 Z"/>
</Canvas>
<Viewbox>
C#
private void Map_PointerEntered(object sender, PointerRoutedEventArgs e)
{
Path p = e.OriginalSource as Path;
if (p != null)
{
p.Fill = new SolidColorBrush(Colors.Red);
}
}
但我收到一条错误消息 "Cannot declare a variable of static type Path"
解决这个问题的最佳方法是什么?
干杯!
P.S。这些只是将显示的 33 个州中的 3 个,以后每个州将有更多区域。
因为.NET/XAML世界中有两个路径classes,Windows.UI.Xaml.Shapes.Path and System.IO.Path,你需要在其中使用完全限定的class名称Windows.UI.Xaml.Shapes.Path上下文,这样它就不会被误认为是 System.IO.Path。
Windows.UI.Xaml.Shapes.Path p = e.OriginalSource as Windows.UI.Xaml.Shapes.Path;
我有一张国家地图,由路径组成的州划分。当指针悬停在每个路径上时,我需要更改每个路径的填充颜色。每个 "state" 都有一个单独的 x:Name。我已经尝试通过 C# 这样做:
XAML
<!-- Layer 1/MxBCN -->
<Path StrokeThickness="0.5" x:Name="MxBCN" Stroke="#ffd7d7d7" PointerEntered="Map_PointerEntered" StrokeMiterLimit="1.0" Fill="#ffffffff" Data="F1 M 89.293,6.893 L 88.493,7.393 L 87.993,6.993 L 86.693,6.993 C 86.526,7.495 86.155,9.255 85.593,9.493 L 85.493,10.793 L 83.693,13.193 L 85.093,15.193 L 84.493,16.993 C 85.165,18.247 84.080,20.512 84.593,21.793 L 83.993,22.793 L 84.993,23.793 L 85.893,23.893 L 89.693,26.693 L 89.693,26.693 L 89.193,28.393 L 90.093,32.393 C 88.320,34.101 88.144,37.499 88.194,39.793 C 88.193,39.793 87.293,42.993 87.293,42.993 L 87.593,43.693 L 87.293,45.893 L 87.893,48.093 L 89.293,49.393 L 88.893,49.993 L 88.893,50.693 L 91.693,52.493 C 92.298,54.522 92.336,59.073 92.193,61.193 C 92.193,61.193 93.893,65.193 93.893,65.193 C 93.928,66.029 93.908,67.911 93.593,68.693 C 93.977,69.258 93.447,70.816 93.293,71.393 L 93.693,71.693 L 92.993,73.893 L 93.993,75.993 L 94.593,76.393 L 96.293,80.393 L 97.493,80.993 L 97.793,81.893 L 98.793,82.093 L 99.393,82.993 C 99.359,83.657 99.343,85.143 99.793,85.693 L 100.593,85.993 L 100.993,86.693 L 102.193,86.793 L 102.493,85.893 L 104.293,86.693 L 105.493,88.193 L 105.793,88.093 L 106.793,89.293 C 107.462,89.499 108.102,90.290 108.393,90.893 L 109.993,91.693 C 110.716,92.560 112.459,94.492 113.593,94.793 L 113.693,95.393 L 115.093,96.093 C 115.800,97.036 117.510,99.154 118.493,99.793 L 118.793,100.693 L 118.093,101.493 L 118.093,101.993 C 118.860,102.887 120.639,105.071 120.993,106.193 L 120.393,107.393 L 120.793,108.993 L 120.493,109.293 L 121.293,110.993 L 122.093,111.093 L 122.593,110.393 L 122.193,109.993 L 122.593,109.393 L 123.093,109.693 L 123.593,109.293 L 123.993,110.093 L 124.593,109.993 L 124.593,110.393 L 124.993,110.493 C 125.009,111.179 125.034,112.932 125.493,113.493 L 126.593,113.493 L 127.893,112.493 L 128.993,113.093 C 129.306,113.899 130.248,118.065 131.193,118.393 L 131.793,121.893 L 134.393,123.393 L 136.793,122.793 L 137.293,123.193 L 137.393,123.893 L 138.193,123.693 L 138.293,124.293 L 137.893,124.793 L 138.193,125.493 L 137.593,128.093 L 139.593,130.893 L 139.093,132.893 L 139.693,134.293 L 139.293,135.493 L 140.193,136.093 C 140.653,136.755 140.288,138.857 140.193,139.593 L 140.193,139.593 L 139.593,137.893 L 138.693,137.593 L 106.993,137.493 L 107.193,136.993 C 106.844,136.697 106.817,135.603 106.793,135.193 L 107.693,136.393 L 108.493,134.993 L 106.893,134.593 L 106.593,132.893 L 108.093,129.893 L 107.693,128.893 L 106.793,129.393 L 106.293,128.893 C 107.103,127.459 108.082,124.425 108.293,122.793 L 106.993,120.593 L 105.393,119.993 L 105.293,117.993 L 104.893,117.593 L 102.693,117.493 L 102.693,116.693 C 102.517,116.238 101.187,115.532 100.793,115.293 L 100.893,114.693 L 100.393,113.493 L 99.493,112.993 L 98.893,111.093 L 98.393,110.993 L 98.193,110.393 C 97.711,109.955 96.866,109.524 96.193,109.593 L 95.993,109.893 L 95.493,108.793 L 94.793,108.393 L 94.593,108.693 C 94.451,107.832 94.101,105.557 93.493,104.893 L 92.393,104.393 L 91.793,104.693 C 91.228,104.183 90.753,103.146 90.693,102.393 L 89.493,101.793 L 89.393,101.393 L 88.993,101.393 C 86.156,97.706 84.661,95.507 79.593,95.293 L 77.993,92.793 C 77.441,92.545 75.426,91.328 74.793,91.593 L 72.793,89.693 L 71.593,89.993 L 69.593,87.793 L 69.093,88.293 L 67.193,86.693 C 67.630,84.467 67.544,82.875 65.993,81.093 L 64.393,80.493 L 64.993,76.893 C 64.283,76.139 64.520,72.445 64.493,71.493 C 64.493,71.493 63.093,68.993 63.093,68.993 L 60.993,67.793 L 61.193,66.393 L 60.393,65.593 L 60.193,65.993 L 60.693,66.893 L 60.193,67.193 L 59.693,66.493 L 59.193,66.493 L 59.793,67.793 L 59.393,67.993 L 58.393,65.993 C 58.768,63.342 59.403,58.605 57.893,56.193 C 57.298,56.241 56.183,55.049 55.793,54.693 L 55.293,54.693 L 52.993,51.693 L 51.493,51.893 L 51.093,51.393 L 51.793,46.093 C 51.225,44.590 49.529,42.216 48.293,41.193 C 47.742,40.192 46.333,37.535 45.193,37.093 L 44.493,37.193 L 44.293,36.193 C 43.853,35.889 42.843,35.192 42.793,34.593 L 42.393,34.693 L 42.293,34.093 L 43.293,33.593 L 42.893,32.693 L 43.393,31.493 L 42.193,29.893 L 41.893,29.993 L 41.093,28.993 L 41.593,28.893 L 43.193,29.793 L 44.193,28.793 L 44.393,26.193 L 43.993,25.593 L 42.693,25.293 L 42.093,24.593 L 40.893,24.393 L 40.493,22.593 L 39.993,22.193 L 38.793,22.193 L 37.593,20.993 C 37.628,19.086 37.350,15.990 36.193,14.393 C 35.648,14.158 33.802,13.649 33.593,12.993 C 33.325,12.066 31.085,6.704 31.493,5.793 L 91.693,0.293 L 90.093,3.093 L 89.393,3.293 L 89.893,5.093 L 89.593,5.293 L 89.293,6.893 L 89.293,6.893 Z M 99.193,79.893 L 99.793,80.693 L 99.393,80.793 L 99.093,80.493 L 99.193,79.893 Z M 120.793,92.393 L 120.793,92.893 L 121.893,92.393 L 121.893,92.693 L 122.793,92.993 C 123.190,93.494 124.207,94.886 124.893,94.993 L 125.993,97.193 L 125.393,98.093 L 125.493,99.293 L 127.293,100.093 L 130.193,99.893 L 130.493,100.193 C 130.422,101.481 130.077,105.082 130.893,106.193 L 132.093,106.593 L 131.793,108.493 L 128.793,106.393 L 127.093,103.993 L 124.493,102.193 L 123.493,100.293 L 122.093,99.993 C 122.246,98.507 119.698,96.918 119.693,95.493 L 120.493,93.593 L 120.293,92.593 L 120.793,92.393 Z M 2.993,102.693 L 2.393,103.993 L 2.593,104.993 L 3.893,106.193 L 4.093,109.093 L 3.393,111.193 L 2.593,111.393 L 1.993,109.993 L 2.193,109.093 L 1.593,108.693 L 1.493,107.093 L 0.293,105.893 L 0.693,104.893 L 0.393,103.893 L 1.093,103.293 L 1.893,103.293 C 1.993,103.393 2.993,102.693 2.993,102.693 Z M 145.793,115.793 L 146.093,116.393 L 145.793,117.393 L 144.593,117.393 L 144.193,115.793 L 145.793,115.793 Z M 137.393,117.293 C 138.080,117.140 140.402,119.428 140.893,119.793 L 140.393,120.293 L 139.793,119.293 L 138.093,118.393 L 137.393,117.293 Z M 79.193,125.893 L 79.793,126.293 L 80.593,129.193 C 80.112,129.863 80.563,131.862 80.693,132.593 L 79.993,133.493 L 79.993,135.593 L 79.393,135.393 L 78.893,135.693 L 78.193,135.393 L 77.593,133.993 L 76.993,133.793 L 75.993,134.393 L 75.593,134.293 L 75.693,133.493 C 76.023,133.061 78.738,130.383 78.593,129.793 L 77.993,128.193 L 78.493,126.293 L 79.193,125.893 Z M 106.593,137.893 L 105.893,137.893 L 105.093,137.993 L 105.193,138.393 C 104.838,138.630 104.126,138.891 103.693,138.793 L 102.893,139.693 L 102.593,138.993 C 102.362,138.364 105.575,134.876 105.893,134.393 L 106.493,134.293 L 106.593,135.293 L 105.793,136.093 L 105.793,136.593 L 106.593,137.893 Z"/>
<!-- Layer 1/MxBCS -->
<Path StrokeThickness="0.5" x:Name="MxBCS" Stroke="#ffd7d7d7" PointerEntered="Map_PointerEntered" StrokeMiterLimit="1.0" Fill="#ffffffff" Data="F1 M 105.893,137.893 L 106.593,137.893 L 106.993,138.293 L 107.293,137.893 L 138.993,137.993 L 139.893,138.293 L 140.493,139.993 L 140.493,139.993 L 140.393,140.493 L 141.693,141.493 L 142.093,143.493 L 143.193,144.793 L 143.593,144.793 L 144.793,146.493 L 147.593,147.393 L 148.093,147.993 C 149.298,147.942 150.737,149.201 151.293,150.193 C 151.293,150.193 151.993,153.893 151.993,153.893 C 152.944,154.724 154.218,156.688 154.593,157.893 L 154.193,158.693 L 156.793,160.793 L 159.293,161.393 L 159.793,161.993 L 160.693,161.993 L 160.793,162.693 L 160.193,162.693 L 159.293,163.693 L 159.093,165.293 C 159.547,165.908 160.851,168.065 161.693,168.193 L 161.693,168.693 L 162.593,169.393 L 162.893,170.793 C 162.313,171.068 161.854,172.117 161.693,172.693 L 162.893,173.393 L 163.193,174.593 L 164.293,175.293 L 164.993,176.993 L 165.993,177.793 L 167.593,176.393 L 164.193,172.793 C 164.182,171.662 163.983,169.238 163.293,168.293 L 163.993,167.793 C 164.723,168.278 166.300,169.425 166.593,170.293 C 167.144,170.602 168.302,171.341 168.493,171.993 C 168.493,171.993 170.693,173.393 170.693,173.393 L 170.493,176.893 L 170.893,177.493 L 173.593,178.393 C 173.275,179.060 172.841,180.447 172.993,181.193 L 174.093,183.093 L 174.793,183.393 C 175.003,183.699 175.070,184.630 175.093,184.993 L 174.693,185.693 L 176.693,190.893 L 176.093,191.793 L 176.193,193.193 L 175.693,193.893 C 175.688,194.350 175.835,195.168 176.193,195.493 L 176.293,197.393 L 176.893,198.093 L 176.893,199.193 L 178.693,200.693 L 178.893,200.493 L 179.693,203.593 L 181.493,205.993 L 184.093,206.293 L 183.893,207.893 L 185.093,210.993 L 185.993,211.893 L 186.293,212.993 L 185.993,213.193 C 186.111,213.820 186.485,215.064 186.993,215.493 L 186.993,216.493 L 187.693,216.993 L 188.093,218.293 L 188.993,218.793 L 189.493,219.693 L 189.993,219.593 L 190.793,220.193 C 190.738,221.168 192.132,222.974 192.694,223.693 C 192.693,223.693 193.393,225.793 193.393,225.793 C 193.252,227.074 192.686,228.902 191.593,229.693 C 191.489,231.782 190.914,233.569 192.693,235.193 L 192.793,238.093 C 193.486,238.655 194.342,240.042 194.593,240.893 C 194.593,240.893 196.093,242.293 196.093,242.293 C 196.984,242.454 200.750,243.428 201.593,243.093 L 201.693,243.393 L 200.393,243.893 L 199.593,243.293 L 199.193,243.593 L 199.393,245.093 L 201.093,244.993 L 201.093,244.193 L 202.293,243.193 C 202.647,242.457 201.771,240.656 201.493,239.993 L 201.793,238.893 L 202.493,238.493 L 204.093,238.693 L 204.093,239.493 L 205.193,240.093 L 205.593,241.193 C 206.781,241.614 208.853,242.954 209.793,243.793 L 210.493,246.993 L 211.693,247.293 L 214.293,246.393 L 214.293,246.993 L 214.793,247.493 L 214.093,248.393 L 214.193,250.393 L 217.393,253.593 C 217.178,254.759 216.849,256.858 217.793,257.793 C 217.793,257.793 223.193,260.393 223.193,260.393 L 222.893,261.193 L 224.293,263.293 L 224.093,263.993 L 224.493,264.393 L 223.993,268.793 C 223.460,270.224 221.812,272.306 220.493,273.093 C 219.591,273.226 217.748,273.709 217.093,274.393 L 217.093,275.193 L 214.993,276.293 C 214.816,276.890 214.140,277.698 213.593,277.993 L 212.693,277.993 L 212.093,278.693 L 210.993,278.693 C 207.009,276.499 206.851,270.650 205.893,266.792 C 205.893,266.793 203.393,262.193 203.393,262.193 L 201.593,259.793 L 195.393,256.493 L 183.793,244.993 C 183.793,244.993 172.993,238.493 172.993,238.493 L 173.093,238.193 C 172.514,237.417 170.973,236.380 170.093,235.993 L 170.193,235.493 L 169.593,235.393 L 168.593,232.393 L 168.893,232.293 L 168.393,231.693 L 167.393,231.393 L 167.293,232.493 L 164.893,232.293 L 164.793,233.093 L 164.193,233.093 C 164.734,230.677 162.953,228.733 161.393,227.193 L 161.693,226.893 L 161.093,226.393 L 160.393,226.693 L 160.493,227.093 C 159.562,227.248 157.867,226.453 157.093,225.993 L 156.793,225.293 L 157.293,225.293 L 157.393,224.493 L 156.793,224.093 L 156.593,223.293 L 157.193,222.293 L 156.893,222.093 L 157.293,221.393 L 156.893,221.293 L 157.093,220.893 L 156.693,220.393 L 156.093,221.293 L 156.393,222.093 L 155.993,222.593 L 156.093,225.093 L 155.393,225.093 L 154.893,223.993 L 155.693,222.393 L 155.093,220.993 L 155.893,220.593 C 156.179,219.984 156.774,218.581 156.593,217.893 L 155.693,217.993 L 155.893,216.093 C 156.394,215.197 157.060,213.323 157.093,212.293 L 157.793,212.193 L 157.893,209.793 L 157.393,209.693 L 157.493,208.493 L 158.093,208.093 L 157.693,207.793 C 157.492,207.229 157.513,206.228 157.793,205.693 L 158.093,205.593 C 158.143,204.747 158.230,202.711 158.093,201.893 L 157.293,200.793 C 157.466,198.846 155.716,194.287 154.993,192.493 C 154.579,191.581 153.062,190.600 152.193,190.193 L 151.293,187.293 L 149.693,185.393 L 148.093,184.993 L 147.893,185.693 L 147.493,185.793 C 147.026,185.478 144.100,183.248 143.593,183.193 L 142.893,183.493 C 142.556,182.571 140.893,181.383 140.093,180.893 L 140.093,180.493 L 139.493,180.493 L 135.893,177.493 C 136.622,177.374 137.667,178.061 138.193,178.493 L 138.293,178.293 C 137.810,177.847 136.758,177.253 136.093,177.193 L 135.393,177.393 L 133.093,175.393 L 133.293,175.193 L 132.893,174.693 L 133.293,174.093 C 132.430,173.192 131.049,171.195 130.693,169.993 L 130.293,171.093 L 128.793,170.393 L 129.093,170.093 L 129.593,170.293 C 130.351,169.600 131.508,168.509 131.593,167.393 L 130.793,164.593 L 130.193,165.193 L 129.793,168.393 L 129.193,168.893 L 128.493,168.693 C 127.989,169.189 128.136,170.670 128.193,171.293 L 127.793,171.393 C 126.993,170.821 125.213,169.770 124.193,169.793 L 124.393,169.293 L 124.893,169.693 L 124.993,169.293 C 124.661,168.975 123.483,169.242 123.093,169.293 C 122.570,169.712 122.007,170.735 121.893,171.393 L 121.293,171.693 L 121.293,172.293 L 120.593,172.693 C 120.153,172.575 119.360,172.164 118.993,171.893 L 118.293,170.493 L 116.693,170.093 L 115.093,166.393 L 113.293,165.093 L 111.093,164.493 L 110.693,164.693 L 110.493,165.293 L 110.093,165.293 C 109.240,164.662 108.115,162.956 107.694,161.993 C 106.632,160.997 104.837,160.342 103.393,160.293 L 102.593,160.993 L 100.193,159.393 L 99.693,159.793 L 99.193,159.493 L 99.293,158.693 L 98.693,158.293 L 98.193,158.393 C 97.863,158.320 98.027,154.751 97.993,154.493 C 97.993,154.493 97.493,152.893 97.493,152.893 L 95.193,150.993 L 91.893,149.793 L 90.693,147.493 L 88.993,146.193 L 88.893,145.193 L 88.193,144.693 L 87.593,145.593 L 86.793,145.193 L 86.493,144.293 L 85.493,143.793 L 84.893,144.093 C 84.585,143.324 83.800,140.892 82.993,140.493 L 83.793,140.093 L 84.893,140.993 C 85.815,140.866 87.795,140.742 88.693,140.993 L 89.093,141.493 C 89.859,141.257 91.335,141.359 92.093,141.593 L 92.593,142.093 C 93.579,142.467 95.958,142.312 96.993,142.193 L 97.593,142.593 L 99.993,141.293 L 100.593,141.693 L 101.393,141.593 L 101.593,140.993 L 100.993,140.993 L 102.093,139.793 L 102.993,140.093 L 102.493,142.593 C 102.825,143.438 104.043,144.610 104.794,145.093 C 105.736,145.198 106.787,146.016 107.393,146.693 L 107.293,147.093 L 108.093,147.393 L 109.093,146.293 L 109.193,145.393 L 111.293,146.093 L 112.893,149.093 L 113.793,149.193 L 114.393,147.993 L 112.793,146.393 L 112.893,145.293 L 113.593,145.893 L 113.793,145.493 L 113.193,145.093 L 113.493,144.493 C 113.285,143.886 112.832,142.508 113.193,141.893 L 111.393,140.493 L 110.393,142.393 L 110.593,143.493 L 107.393,144.693 L 105.793,143.493 L 105.993,142.993 L 106.593,143.493 L 105.893,141.493 L 107.093,139.793 C 106.658,139.535 106.103,138.333 105.893,137.893 L 105.893,137.893 Z M 79.193,139.393 L 80.593,140.193 L 80.493,140.693 L 79.093,139.693 L 79.193,139.393 Z M 162.593,151.793 L 162.993,151.893 L 163.293,152.493 L 162.393,152.493 L 162.193,151.993 L 162.593,151.793 Z M 157.493,157.293 L 158.593,158.293 L 158.293,159.493 L 157.693,159.293 L 157.093,157.993 L 157.493,157.293 Z M 128.893,172.093 L 130.193,172.393 L 130.993,173.993 C 130.423,173.468 128.735,173.042 127.993,172.893 L 127.893,172.593 L 128.893,172.093 Z M 177.993,188.593 L 178.193,189.393 L 177.793,189.493 L 177.593,188.993 L 177.993,188.593 Z M 183.193,190.493 L 182.693,191.493 L 183.093,193.193 L 181.893,192.493 L 180.193,195.193 L 180.193,196.093 L 179.593,196.693 L 179.593,197.393 L 178.993,197.493 L 178.893,196.693 L 179.293,196.293 L 179.493,194.593 L 180.593,192.893 L 180.393,191.393 L 181.393,191.093 L 181.593,190.693 L 182.193,191.093 L 183.193,190.493 L 183.193,190.493 Z M 183.893,200.293 L 184.393,201.593 L 184.093,202.093 L 183.693,201.893 L 183.293,200.493 L 183.893,200.293 Z M 190.393,200.293 L 190.693,203.593 L 189.993,203.193 L 189.593,201.793 L 190.393,200.293 Z M 157.393,201.293 C 157.609,202.430 157.557,204.745 157.393,205.893 L 157.093,205.893 L 157.393,201.293 L 157.393,201.293 Z M 157.293,206.493 C 157.235,207.561 157.199,211.367 156.693,212.293 L 156.193,211.893 L 157.293,206.493 L 157.293,206.493 Z M 192.493,211.393 L 192.093,212.593 L 191.593,212.793 L 191.493,212.093 L 192.493,211.393 Z M 156.493,212.493 C 157.027,213.497 155.905,216.325 155.593,217.293 C 155.593,217.293 155.693,220.393 155.693,220.393 L 154.893,221.093 L 155.593,222.393 L 155.293,223.493 L 154.693,223.593 L 154.393,224.093 C 154.372,224.655 155.356,225.704 155.693,226.093 L 155.493,226.393 L 156.393,227.193 L 156.793,228.493 L 156.093,229.593 C 156.754,230.013 157.856,231.544 158.293,232.193 L 158.193,232.593 L 157.093,232.093 L 156.993,231.393 L 155.193,229.493 L 155.393,228.993 L 155.993,229.093 C 156.259,228.774 156.140,227.864 156.093,227.493 C 155.741,226.832 154.682,226.053 153.993,225.793 L 152.793,226.193 L 152.093,225.793 L 152.093,225.193 L 152.493,225.093 C 153.719,222.162 155.681,215.604 156.493,212.493 L 156.493,212.493 Z M 192.093,217.093 L 192.993,218.493 L 194.993,218.993 C 195.455,219.340 195.475,220.586 195.493,221.093 C 195.493,221.093 196.493,223.293 196.493,223.293 L 195.993,223.393 L 193.393,221.393 C 193.163,220.560 192.589,218.963 191.793,218.493 L 192.093,217.093 Z M 199.893,231.193 L 200.793,232.493 L 200.193,232.793 L 199.593,232.393 L 199.493,231.593 L 199.893,231.193 Z M 200.793,232.793 L 202.593,234.393 L 201.693,236.393 L 201.193,236.393 L 201.193,235.593 L 200.493,235.293 L 200.593,234.793 L 200.093,234.193 L 200.293,233.493 L 199.993,232.993 L 200.793,232.793 Z M 159.993,232.993 L 163.093,233.193 L 164.193,234.593 L 165.093,234.693 C 165.862,234.927 166.841,237.059 167.193,237.693 L 166.793,238.493 L 159.893,233.493 L 159.593,233.193 L 159.993,232.993 Z M 211.493,237.093 C 212.222,238.312 214.814,242.114 214.693,243.593 L 213.093,243.293 C 212.211,242.089 211.011,238.573 211.493,237.093 L 211.493,237.093 Z M 91.193,397.593 L 92.693,397.993 C 92.422,398.425 91.340,398.539 90.893,398.593 L 90.793,397.893 C 90.693,397.793 91.193,397.593 91.193,397.593 Z"/>
<!-- Layer 1/MxCAM -->
<Path StrokeThickness="0.5" x:Name="MxCAM" Stroke="#ffd7d7d7" PointerEntered="Map_PointerEntered" StrokeMiterLimit="1.0" Fill="#ffffffff" Data="F1 M 700.793,333.493 L 700.593,340.793 L 704.693,341.293 L 705.693,343.293 L 706.193,343.493 L 707.293,343.093 L 708.193,344.093 L 708.693,343.993 C 708.815,343.410 709.382,342.599 709.893,342.293 C 710.295,342.380 711.096,344.080 711.293,344.393 L 711.193,345.293 C 711.409,346.118 712.916,347.089 713.593,347.493 L 715.593,351.993 L 719.493,354.093 C 719.952,355.847 722.649,358.917 723.894,360.193 C 724.029,360.632 724.610,363.904 725.093,364.093 L 725.093,364.093 C 725.668,365.590 730.463,369.171 731.694,370.193 C 731.693,370.193 735.093,374.893 735.093,374.893 L 734.893,380.793 C 734.402,381.036 733.426,381.601 733.293,382.193 C 733.954,384.530 732.385,388.784 732.893,391.093 C 733.230,391.477 734.102,392.441 734.093,392.993 L 733.593,394.393 L 734.393,394.893 L 733.793,396.593 C 734.426,397.474 734.507,401.623 734.593,402.693 C 734.397,403.710 732.255,406.021 731.593,406.793 L 731.893,409.293 L 731.893,409.293 L 731.893,412.593 L 685.993,412.593 L 685.993,412.593 L 685.993,410.993 L 681.993,409.393 L 681.293,409.793 C 680.919,409.091 679.613,408.429 678.893,408.193 C 678.893,408.193 677.293,406.693 677.293,406.693 C 675.706,406.231 672.430,405.698 670.793,405.993 C 670.437,406.755 670.580,408.307 670.793,409.093 L 670.493,409.793 C 669.667,409.742 668.182,410.010 667.493,410.493 L 665.293,409.393 L 663.793,409.493 L 662.493,408.793 L 661.593,407.393 C 658.332,405.494 657.042,404.354 655.793,400.693 L 655.293,400.393 L 655.493,398.393 C 655.268,398.137 654.373,396.809 653.993,396.793 L 653.893,397.193 L 653.393,397.293 L 652.693,396.193 L 651.693,396.193 C 649.456,395.149 649.249,392.621 648.593,390.593 L 648.593,390.593 C 650.628,389.902 659.232,389.543 661.493,389.393 L 662.393,390.793 L 663.893,391.593 L 663.293,392.793 L 662.993,392.393 L 662.694,392.693 L 661.694,391.393 L 660.993,392.293 L 660.293,391.893 L 660.093,392.093 L 660.293,392.793 L 659.793,393.393 L 660.393,394.093 L 661.593,393.793 L 661.093,392.693 L 661.893,392.693 L 662.193,393.193 L 662.793,393.093 L 663.893,393.793 L 664.093,394.393 C 665.124,394.587 671.362,396.478 672.293,395.993 C 672.182,394.237 676.657,393.638 677.693,393.093 L 678.493,390.193 L 679.093,389.893 C 679.232,389.411 679.498,388.355 679.193,387.893 L 678.093,386.893 L 677.193,387.593 L 675.993,386.993 L 675.693,385.993 L 676.293,385.493 L 676.193,384.693 L 677.193,383.693 L 676.393,383.893 C 676.138,384.490 675.471,385.561 674.893,385.893 L 674.393,385.893 L 673.593,386.693 L 673.493,387.293 L 672.893,387.293 L 672.893,387.093 L 675.393,384.493 L 682.193,380.793 C 685.066,378.688 690.438,374.921 692.393,371.893 C 692.146,371.224 692.608,369.548 692.794,368.893 C 692.793,368.893 692.593,366.693 692.593,366.693 L 693.293,364.893 L 692.793,364.293 L 692.793,363.693 C 693.266,363.224 693.919,362.296 693.894,361.593 L 697.694,358.693 L 699.094,356.193 L 698.094,353.493 L 698.394,352.093 L 697.993,350.793 L 698.394,350.493 C 698.394,349.824 697.730,345.678 698.294,345.193 C 698.293,345.193 697.793,341.793 697.793,341.793 L 699.093,338.193 L 699.493,335.193 L 700.793,333.493 L 700.793,333.493 Z M 672.093,386.893 L 672.593,387.693 C 672.340,387.935 671.750,388.433 671.393,388.493 L 670.293,387.893 L 669.893,388.193 L 670.293,388.493 L 668.593,389.793 L 668.093,389.093 L 667.793,389.693 C 667.105,390.009 665.367,390.803 664.593,390.693 L 664.093,390.093 L 664.393,389.793 C 666.114,389.909 670.567,387.630 672.093,386.893 Z"/>
</Canvas>
<Viewbox>
C#
private void Map_PointerEntered(object sender, PointerRoutedEventArgs e)
{
Path p = e.OriginalSource as Path;
if (p != null)
{
p.Fill = new SolidColorBrush(Colors.Red);
}
}
但我收到一条错误消息 "Cannot declare a variable of static type Path"
解决这个问题的最佳方法是什么?
干杯!
P.S。这些只是将显示的 33 个州中的 3 个,以后每个州将有更多区域。
因为.NET/XAML世界中有两个路径classes,Windows.UI.Xaml.Shapes.Path and System.IO.Path,你需要在其中使用完全限定的class名称Windows.UI.Xaml.Shapes.Path上下文,这样它就不会被误认为是 System.IO.Path。
Windows.UI.Xaml.Shapes.Path p = e.OriginalSource as Windows.UI.Xaml.Shapes.Path;