【发布时间】:2017-12-27 15:33:31
【问题描述】:
<Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" ... />
尝试在后面的代码中创建这样的按钮:
var button = new Button
{
Style = (Style)Application.Current.FindResource("ToolBar.ButtonStyleKey"), // wrong
BorderThickness = new Thickness(0),
...
};
会抛出:
“System.Windows.ResourceReferenceKeyNotFoundException”类型的异常发生在 WindowsBase.dll 中,但未在用户代码中处理
附加信息:未找到“ToolBar.ButtonStyleKey”资源。
【问题讨论】:
标签: c# wpf code-behind markup-extensions