OnApplyTemplate not called in Custom Control

前端 未结 6 2047
忘掉有多难
忘掉有多难 2021-02-01 21:47

I have a Custom Control which uses some PART controls:

 [TemplatePart(Name = \"PART_TitleTextBox\", Type = typeof(TextBox))]
    [TemplatePart(Name = \"PART_Titl         


        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 22:25

    For anyone else who might stumble upon this post, I was having the same issue and I managed to solve it by adding the following into the AssemblyInfo.cs of the project containing my custom control:

    [assembly: ThemeInfo(
        ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
        //(used if a resource is not found in the page, 
        // or application resource dictionaries)
        ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
        //(used if a resource is not found in the page, 
        // app, or any theme specific resource dictionaries)
    )]
    

    My control's template is located in the file Theme/Generic.xaml in the same project as the control.

提交回复
热议问题