如何绑定StreamGeometry中的路径数据

时间:2016-07-12 11:58:46

标签: wpf xaml data-binding path

我是wpf的新手。我想通过path.i绘制图标,包含xaml文件,包括StreamGeometry中的所有路径数据,如此

<StreamGeometry x:Key="IconLogin" >
    F1M9.377,5.632C9.5,5.562 9.652,5.562 9.775,5.632 9.775,5.632 17.63,10.156 17.63,10.156 17.753,10.227 17.829,10.358 17.829,10.5 17.829,10.642 17.753,10.773 17.63,10.844 17.63,10.844 9.775,15.367 9.775,15.367 9.714,15.403 9.645,15.42 9.576,15.42 9.507,15.42 9.439,15.402 9.377,15.367 9.254,15.296 9.178,15.165 9.178,15.023 9.178,15.023 9.178,12.917 9.178,12.917 9.178,12.917 2.397,12.917 2.397,12.917 2.177,12.917 1.999,12.739 1.999,12.52 1.999,12.52 1.999,8.48 1.999,8.48 1.999,8.26 2.177,8.082 2.397,8.082 2.397,8.082 9.178,8.082 9.178,8.082 9.178,8.082 9.178,5.976 9.178,5.976 9.178,5.835 9.254,5.703 9.377,5.632z M9.945,1C9.945,1 18.059,1 18.059,1 19.681,1 21.001,2.316 21.001,3.934 21.001,3.934 21.001,17.066 21.001,17.066 21.001,18.683 19.681,19.999 18.059,19.999 18.059,19.999 9.945,19.999 9.945,19.999 9.725,19.999 9.547,19.821 9.547,19.602 9.547,19.602 9.547,18.41 9.547,18.41 9.547,18.191 9.725,18.013 9.945,18.013 9.945,18.013 18.059,18.013 18.059,18.013 18.583,18.013 19.009,17.588 19.009,17.066 19.009,17.066 19.009,3.934 19.009,3.934 19.009,3.412 18.583,2.986 18.059,2.986 18.059,2.986 9.945,2.986 9.945,2.986 9.725,2.986 9.547,2.808 9.547,2.589 9.547,2.589 9.547,1.398 9.547,1.398 9.547,1.178 9.725,1 9.945,1z
</StreamGeometry>

<!--<StreamGeometry x:Key="icon_login_d">
    F1M10.5,5.171C10.642,5.171 10.773,5.247 10.844,5.37 10.844,5.37 15.367,13.225 15.367,13.225 15.403,13.286 15.42,13.355 15.42,13.424 15.42,13.493 15.402,13.561 15.367,13.623 15.296,13.746 15.165,13.822 15.023,13.822 15.023,13.822 12.917,13.822 12.917,13.822 12.917,13.822 12.917,20.603 12.917,20.603 12.917,20.823 12.739,21.001 12.52,21.001 12.52,21.001 8.48,21.001 8.48,21.001 8.26,21.001 8.082,20.823 8.082,20.603 8.082,20.603 8.082,13.822 8.082,13.822 8.082,13.822 5.976,13.822 5.976,13.822 5.834,13.822 5.703,13.746 5.632,13.623 5.561,13.5 5.561,13.348 5.632,13.225 5.632,13.225 10.156,5.37 10.156,5.37 10.227,5.247 10.358,5.171 10.5,5.171z M3.934,1.999C3.934,1.999 17.066,1.999 17.066,1.999 18.683,1.999 19.999,3.319 19.999,4.941 19.999,4.941 19.999,13.055 19.999,13.055 19.999,13.275 19.821,13.453 19.602,13.453 19.602,13.453 18.41,13.453 18.41,13.453 18.191,13.453 18.013,13.275 18.013,13.055 18.013,13.055 18.013,4.941 18.013,4.941 18.013,4.417 17.588,3.991 17.066,3.991 17.066,3.991 3.934,3.991 3.934,3.991 3.412,3.991 2.986,4.417 2.986,4.941 2.986,4.941 2.986,13.055 2.986,13.055 2.986,13.275 2.808,13.453 2.589,13.453 2.589,13.453 1.398,13.453 1.398,13.453 1.178,13.453 1,13.275 1,13.055 1,13.055 1,4.941 1,4.941 1,3.319 2.316,1.999 3.934,1.999z
</StreamGeometry>-->

<StreamGeometry x:Key="IconWorld" >
    F1M3.355,5.113C3.355,5.113 2.886,5.485 2.886,5.485 2.886,5.485 3.254,5.726 3.254,5.726 3.254,5.726 3.985,5.726 3.985,5.726 3.985,5.726 5.07,5.532 5.07,5.532 5.07,5.532 5.754,6.643 5.754,6.643 5.754,6.643 5.754,7.681 5.754,7.681 5.754,7.681 6.686,8.946 6.686,8.946 6.686,8.946 6.844,8.946 6.844,8.946 6.844,8.946 6.844,8.499 6.844,8.499 6.844,8.499 7.203,9.251 7.203,9.251 7.203,9.251 8.285,9.493 8.285,9.493 8.285,9.493 8.774,9.983 8.774,9.983 8.774,9.983 9.209,10.114 9.209,10.114 9.209,10.114 8.774,11.02 8.774,11.02 8.774,11.02 9.248,11.899 9.248,11.899 9.248,11.899 9.545,12.909 9.546,12.95 9.546,12.989 9.248,14.16 9.248,14.16 9.248,14.16 9.316,14.948 9.316,14.948 9.047,14.98 8.776,15.004 8.499,15.004 4.906,15.004 1.994,12.091 1.994,8.499 1.994,7.302 2.323,6.184 2.887,5.221 2.887,5.221 3.355,5.113 3.355,5.113z M9.931,3.306C9.931,3.306 10.543,3.425 10.543,3.425 10.543,3.425 11.062,3.89 11.062,3.89 11.062,3.89 11.221,4.303 11.221,4.303 11.221,4.303 11.342,4.69 11.342,4.69 11.342,4.69 12.167,5.434 12.167,5.434 12.167,5.434 12.379,5.501 12.379,5.501 12.379,5.501 12.672,5.033 12.672,5.033 12.672,5.033 13.709,4.941 13.709,4.941 13.709,4.941 13.903,4.879 13.903,4.879 14.599,5.913 15.004,7.16 15.004,8.499 15.004,11.564 12.88,14.128 10.026,14.816 10.026,14.816 10.145,14.385 10.145,14.385 10.145,14.385 11.261,13.64 11.261,13.64 11.261,13.64 11.554,12.842 11.554,12.842 11.554,12.842 12.326,12.484 12.326,12.484 12.326,12.484 13.057,11.087 13.057,11.087 13.057,11.087 11.927,10.422 11.927,10.422 11.927,10.422 11.342,9.757 11.342,9.757 11.342,9.757 10.995,9.717 10.995,9.717 10.995,9.717 10.304,9.53 10.304,9.53 10.304,9.53 9.708,9.437 9.708,9.437 9.708,9.437 9.187,9.583 9.187,9.583 9.187,9.583 8.868,9.225 8.868,9.225 8.868,9.225 8.548,9.131 8.548,9.131 8.548,9.131 8.574,8.653 8.574,8.653 8.574,8.653 8.188,8.665 8.188,8.665 8.188,8.665 7.969,8.919 7.969,8.919 7.969,8.919 7.843,8.386 7.843,8.386 7.843,8.386 8.348,8.147 8.348,8.147 8.348,8.147 8.868,8.386 8.868,8.386 8.868,8.386 9.146,8.386 9.146,8.386 9.146,8.386 9.247,7.974 9.247,7.974 9.247,7.974 10.025,7.042 10.025,7.042 10.025,7.042 11.103,6.498 11.103,6.498 11.103,6.498 11.727,6.577 11.727,6.577 11.727,6.577 11.784,6.272 11.784,6.272 11.784,6.272 11.01,5.487 11.01,5.487 11.01,5.487 10.717,4.902 10.717,4.902 10.717,4.902 10.291,4.902 10.291,4.902 10.291,4.902 10.025,4.746 10.025,4.746 10.025,4.746 9.453,4.662 9.453,4.662 9.453,4.662 9.333,5.342 9.333,5.342 9.333,5.342 8.64,5.208 8.64,5.208 8.64,5.208 8.588,4.783 8.588,4.783 8.588,4.783 9.12,4.662 9.12,4.662 9.12,4.662 9.295,3.9 9.295,3.9 9.295,3.9 9.822,4.117 9.822,4.117 9.822,4.117 9.809,4.441 9.809,4.441 9.809,4.441 10.211,4.609 10.211,4.609 10.211,4.609 10.48,4.688 10.48,4.688 10.48,4.688 10.81,4.516 10.81,4.516 10.81,4.516 10.516,4.17 10.516,4.17 10.516,4.17 9.917,3.586 9.917,3.586 9.917,3.586 9.931,3.306 9.931,3.306z M6.806,2.694C6.796,2.771 6.379,3.04 6.379,3.04 6.379,3.04 6.806,3.289 6.806,3.289 6.806,3.289 7.692,3.056 7.692,3.056 7.692,3.056 7.483,2.694 7.483,2.694 7.483,2.694 7.099,2.816 7.099,2.816 7.099,2.816 6.806,2.694 6.806,2.694z M9.439,2.275C9.439,2.275 8.774,2.641 8.774,2.641 8.774,2.641 8.392,2.878 8.392,2.878 8.392,2.878 8.658,3.051 8.658,3.051 8.658,3.051 9.247,2.991 9.247,2.991 9.247,2.991 9.865,2.521 9.865,2.521 9.865,2.521 9.439,2.275 9.439,2.275z M8.499,1.994C9.49,1.994 10.427,2.223 11.269,2.618 11.269,2.618 11.035,2.654 11.035,2.654 11.035,2.654 10.397,2.558 10.397,2.558 10.397,2.558 9.945,2.859 9.945,2.859 9.945,2.859 9.626,3.212 9.626,3.212 9.626,3.212 8.463,3.321 8.463,3.321 8.463,3.321 7.985,3.242 7.985,3.242 7.985,3.242 7.657,3.758 7.657,3.758 7.657,3.758 6.699,3.811 6.699,3.811 6.699,3.811 6.1,3.638 6.1,3.638 6.1,3.638 5.567,3.93 5.567,3.93 5.567,3.93 4.411,4.091 4.411,4.091 4.411,4.091 3.485,4.359 3.485,4.359 3.485,4.359 3.482,4.359 3.482,4.359 4.674,2.914 6.479,1.994 8.499,1.994z
</StreamGeometry>

任何人都可以帮助我如何在我想要显示图标的路径对象中绑定此密钥

1 个答案:

答案 0 :(得分:2)

你不会绑定它,而只是分配一个StaticResource:

<Path Data="{StaticResource IconLogin}" Fill="Black" />

除此之外,没有必要明确声明StreamGeometry资源。你也可以使用Geometry

<Geometry x:Key="IconLogin">
    ...
</Geometry>