目前,我可以使用类似于以下内容的控件向控件添加资源:
Button b = new Button();
b.Resources.Add("item", currentItem);
我想用 XAML 来做这件事。我试过类似的东西
<Button Content="Timers Overview" Name="btnTimerOverview">
<Button.Resources>
<ResourceDictionary>
<!-- not sure what to add here, or if this is even correct -->
<!-- I'd like to add something like a <string, string> mapping -->
<!-- like name="items" value="I am the current item." -->
</ResourceDictionary>
</Button.Resources>
</Button>
但我没有比这更进一步。有没有办法在 XAML 中做到这一点?