我有兩個圖片添加到專案里了, 用于Image的Source,<Image Source="../Image/123.png" />
現在我想在ResourceDictionary里添加一個key, 讓這個key可以用DynamicResource的方式系結到Source里該怎么做?
我說的不太準確, 舉個string的例子吧,
rec.xaml里的ResourceDictionary里面, 有個key是 <sys:String x:Key="Logon">登錄</sys:String>, 然后我其他xaml里某控制元件的Text屬性這么寫, Text="{DynamicResource Logon}", 這樣Text就會顯示為登錄, 現在我想把Image的Source也像這么搞, 如果我用一個String的key,會提示我string無法應用到system.windows.media.imagesource里,
rec.xaml里的sys是這么寫的 xmlns:sys="clr-namespace:System;assembly=mscorlib", 但是怎么在rec.xaml里能弄個system.windows.media.imagesource型別的key? 弄個ImageSource的key是不是就可以 <Image Source="{DynamicResource img}" />?
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/270132.html
標籤:C#
