'WidgetStyle': undeclared identifier

I’m trying to make a TextBlock Widget with a predefined style. This code works for a button but a TextBlock does not have a WidgetStyle? I can create a SlateWidgetStyleAsset in the UE4 editor so it would only make sense it also has a WidgetStyle right? I got it to work for a Button but I can’t get it to work for the TextBlock.

VS output Error: …\TextBlock_Styled.cpp(15): error C2065: ‘WidgetStyle’: undeclared identifier

I enabled this line in the build-file: PrivateDependencyModuleNames.AddRange(new string[] { “Slate”, “SlateCore” });

And the documentation for TextBlock is awesome: TextBlock | Unreal Engine Documentation (1 whole line of text).

#include "Runtime/UMG/Public/UMG.h"
#include "Components/TextBlock.h"
#include "TextBlock_Styled.generated.h"

/**
 * 
 */
UCLASS(meta = (DisplayName = "TextBlock Styled"))
class FPS2_API UTextBlock_Styled : public UTextBlock
{
	GENERATED_BODY()

	UTextBlock_Styled();
	
#if WITH_EDITOR
	virtual const FText GetPaletteCategory() override;
#endif
};


#include "FPS2.h"
#include "TextBlock_Styled.h"

#define LOCTEXT_NAMESPACE "UMG"

UTextBlock_Styled::UTextBlock_Styled()
{
	static ConstructorHelpers::FObjectFinder<USlateWidgetStyleAsset> CustomStyle(TEXT("/Game/GUI/Styles/TextBlock_SWS"));

	STextBlock::FArguments TextBlockDefaults;
	TextBlockDefaults.TextStyle(CustomStyle.Object);
	WidgetStyle = *TextBlockDefaults._TextStyle; // <<<<<<<<<<<<<< ERROR here.
}

#if WITH_EDITOR
const FText UTextBlock_Styled::GetPaletteCategory()
{
	return LOCTEXT("", "Custom");
}
#endif

#undef LOCTEXT_NAMESPACE

This question is very old, but we had same issue.

We Fixed it with:
#include “Runtime/SlateCore/Public/Styling/WidgetStyle.h”