{"record":{"id":"17af269699799338","repo":"AvaloniaUI/Avalonia","slug":"controltheme-has-no-targettype-17af26","errorCode":null,"errorMessage":"ControlTheme has no TargetType.","messagePattern":"ControlTheme has no TargetType\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Styling/NestingSelector.cs","lineNumber":25,"sourceCode":"    /// </summary>\n    internal class NestingSelector : Selector\n    {\n        internal override bool InTemplate => false;\n        internal override bool IsCombinator => false;\n        internal override Type? TargetType => null;\n\n        public override string ToString(Style? owner) => owner?.Parent?.ToString() ?? \"^\";\n\n        private protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)\n        {\n            if (parent is Style s && s.Selector is not null)\n            {\n                return s.Selector.Match(control, s.Parent, subscribe);\n            }\n            else if (parent is ControlTheme theme)\n            {\n                if (theme.TargetType is null)\n                    throw new InvalidOperationException(\"ControlTheme has no TargetType.\");\n                return theme.TargetType.IsAssignableFrom(control.StyleKey) ?\n                    SelectorMatch.AlwaysThisType :\n                    SelectorMatch.NeverThisType;\n            }\n            else if (parent is ContainerQuery query && query.Parent is ControlTheme queryTheme)\n            {\n                if (queryTheme.TargetType is null)\n                    throw new InvalidOperationException(\"ControlTheme has no TargetType.\");\n                return queryTheme.TargetType.IsAssignableFrom(control.StyleKey) ?\n                    SelectorMatch.AlwaysThisType :\n                    SelectorMatch.NeverThisType;\n            }\n\n            throw new InvalidOperationException(\n                \"Nesting selector was specified but cannot determine parent selector.\");\n        }\n\n        private protected override Selector? MovePrevious() => null;","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Styling/NestingSelector.cs#L7-L43","documentation":"Error \"ControlTheme has no TargetType.\" thrown in AvaloniaUI/Avalonia.","triggerScenarios":"Raised when a nesting selector is resolved against a ControlTheme that has no TargetType. Defend by setting TargetType on the ControlTheme so nested selectors can be built against a concrete type.","commonSituations":"See trigger scenarios.","solutions":["Set the ControlTheme's TargetType property before using a nesting selector inside it.","Replace the nesting selector (^) with an explicit selector if no parent ControlTheme TargetType exists."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}