Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 在新Groupbox I';中未找到SetResourceReference;我在代码隐藏中创建_Wpf_Templates_Powerbuilder - Fatal编程技术网

Wpf 在新Groupbox I';中未找到SetResourceReference;我在代码隐藏中创建

Wpf 在新Groupbox I';中未找到SetResourceReference;我在代码隐藏中创建,wpf,templates,powerbuilder,Wpf,Templates,Powerbuilder,我想在我在代码隐藏中创建的groupbox中设置对模板的引用。在我发现的一个示例中,它们大多使用SetResourceReference方法。但是,我看到在创建时,新的Groupbox属性上似乎不存在此方法。 XAML: <ControlTemplate TargetType="GroupBox" x:Key="GBTemplate"> 这个方法有两个错误, 1.未定义变量:TemplateProperty 2.找不到元素SetResourceReference如果要为groupb

我想在我在代码隐藏中创建的groupbox中设置对模板的引用。在我发现的一个示例中,它们大多使用SetResourceReference方法。但是,我看到在创建时,新的Groupbox属性上似乎不存在此方法。 XAML:

<ControlTemplate TargetType="GroupBox" x:Key="GBTemplate">
这个方法有两个错误, 1.未定义变量:TemplateProperty
2.找不到元素SetResourceReference

如果要为groupbox设置控件模板,则必须执行以下操作:

 gb_plate.Template = Resources["GBTemplate"] as ControlTemplate;

谢谢,但是现在出现了错误:语法错误:“控制模板”和“模板”附近的语法错误您是用C#还是VB.net编写的?
 gb_plate.Template = Resources["GBTemplate"] as ControlTemplate;