{"record":{"id":"5f2807562e6c6b87","repo":"dotnet/wpf","slug":"sr-track-samebuttons","errorCode":null,"errorMessage":"SR.Track_SameButtons","messagePattern":"SR\\.Track_SameButtons","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Track.cs","lineNumber":164,"sourceCode":"                InvalidateMeasure();\n                InvalidateArrange();\n            }\n        }\n\n        /// <summary>\n        /// The RepeatButton used to decrease the Value\n        /// </summary>\n        public RepeatButton DecreaseRepeatButton\n        {\n            get\n            {\n                return _decreaseButton;\n            }\n            set\n            {\n                if (_increaseButton == value)\n                {\n                    throw new NotSupportedException(SR.Track_SameButtons);\n                }\n                UpdateComponent(_decreaseButton, value);\n                _decreaseButton = value;\n\n                if (_decreaseButton != null)\n                {\n                    CommandManager.InvalidateRequerySuggested(); // Should post an idle queue item to update IsEnabled on button\n                }\n            }\n        }\n\n        /// <summary>\n        /// The Thumb in the Track\n        /// </summary>\n        public Thumb Thumb\n        {\n            get\n            {","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Track.cs#L146-L182","documentation":"Track.DecreaseButton setter throws NotSupportedException when the value being assigned is the same object already stored in IncreaseButton. A Track must never use one Button for both the increase and decrease repeat buttons, so the assignment is rejected before UpdateComponent runs.","triggerScenarios":"x:Name-ing or assigning the same Button instance (or template-resolved reference) to both DecreaseButton and IncreaseButton on a Track, typically via a custom ScrollBar/Slider template that reuses one button element.","commonSituations":"Minimal custom ScrollBar templates where a developer gives both repeat-button slots the same named part; code-behind that wires one button object to both properties.","solutions":["Provide two distinct Button instances (or two distinct template parts) for DecreaseButton and IncreaseButton.","In a custom template, define two separate RepeatButton parts with different names/styles and bind each to its Track property.","If one visual style is desired, duplicate the element with shared style rather than sharing the instance."],"exampleFix":"// before\n<Track.DecreaseButton>\n  <RepeatButton x:Name=\"btn\" Command=\"ScrollBar.DecreaseSmall\"/>\n</Track.DecreaseButton>\n<Track.IncreaseButton>\n  <RepeatButton Command=\"{Binding Command, ElementName=btn}\"/> <!-- same instance pattern -> throws when identical -->\n</Track.IncreaseButton>\n// after\n<Track.DecreaseButton>\n  <RepeatButton Command=\"ScrollBar.DecreaseSmall\"/>\n</Track.DecreaseButton>\n<Track.IncreaseButton>\n  <RepeatButton Command=\"ScrollBar.IncreaseSmall\"/> <!-- distinct instance -->\n</Track.IncreaseButton>","handlingStrategy":"validation","validationCode":"if (newButton != null && !ReferenceEquals(newButton, track.IncreaseButton)) track.DecreaseButton = newButton;","typeGuard":"static bool CanSetDecreaseButton(Track track, Button value) => value == null || !ReferenceEquals(track.IncreaseButton, value);","tryCatchPattern":"try\n{\n    track.DecreaseButton = value;\n}\ncatch (NotSupportedException)\n{\n    // same instance as IncreaseButton; create a distinct button\n}","preventionTips":["Always create two distinct button instances for a Track","Never share one part name between Decrease/Increase bindings","Use separate styles instead of shared instances for identical visuals"],"tags":["wpf","track","scrollbar","not-supported"],"backgroundTag":"invalid-argument-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}