- jatingargrx
- Posts: 2
- Joined:
Setting DataContext using Unreal C++ class
Hi,
I am working on Unreal Engine and was trying to set a custom object class as data context, but can't construct the class in 'View' (Screenshot attached)
https://drive.google.com/file/d/1Rur29k ... sp=sharing
My C++ code
DataContext class name - BindingTest
cpp file
My Xaml file is (ButtonTest.xaml)
The same thing is working if I make the Data Context class as a blueprint class. But want to use c++
I am new to Noesis. Please let me know if I am missing anything.
I am working on Unreal Engine and was trying to set a custom object class as data context, but can't construct the class in 'View' (Screenshot attached)
https://drive.google.com/file/d/1Rur29k ... sp=sharing
My C++ code
DataContext class name - BindingTest
Code: Select all
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "NoesisRuntime.h"
#include "BindingTest.generated.h"
/**
*
*/
UCLASS()
class NOESISGUISAMPLE_API UBindingTest : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite)
int32 Value = 0;
UFUNCTION(BlueprintCallable)
void SetValue(int32 value1);
UFUNCTION(BlueprintCallable)
int32 GetValue() const;
UFUNCTION(BlueprintCallable)
void UpButton_Click();
UFUNCTION(BlueprintCallable)
void DownButton_Click();
};
Code: Select all
#include "BindingTest.h"
void UBindingTest::SetValue(int32 value1)
{
Value = value1;
}
int32 UBindingTest::GetValue() const
{
return Value;
}
void UBindingTest::UpButton_Click(){
Value++;
UE_LOG(LogTemp,Warning, TEXT("Up button clicked"));
}
void UBindingTest::DownButton_Click()
{
Value--;
UE_LOG(LogTemp, Warning, TEXT("Down button clicked"));
}
Code: Select all
<UserControl x:Class="Demo.GUI.ButtonTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="NumericUpDownControl">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Grid.RowSpan="2" Grid.ColumnSpan="2" BorderThickness="1"
BorderBrush="#40484F" Background="#20282F"/>
<TextBlock Grid.RowSpan="2" VerticalAlignment="Center" Margin="5,3,4,3" Width="50" Text="{Binding Value}"/>
<RepeatButton Name="UpButton" Grid.Column="1" Grid.Row="0" Padding="4,1" Margin="0,2,2,0" Command="{Binding UpButton_Click}">
<Path Data="M1,1L4,4 7,1" Stroke="Black" StrokeThickness="2"
StrokeStartLineCap="Round" StrokeEndLineCap="Round" RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<ScaleTransform ScaleY="-1"/>
</Path.RenderTransform>
</Path>
</RepeatButton>
<RepeatButton Name="DownButton" Grid.Column="1" Grid.Row="1" Padding="4,1" Margin="0,0,2,2" Command="{Binding DownButton_Click}">
<Path Data="M1,1L4,4 7,1" Stroke="Black" StrokeThickness="2"
StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
</RepeatButton>
</Grid>
</UserControl>
I am new to Noesis. Please let me know if I am missing anything.
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Setting DataContext using Unreal C++ class
The class must be marked as BlueprintType, since you want to use the result in blueprint:
https://docs.unrealengine.com/4.27/en-U ... pecifiers/
https://docs.unrealengine.com/4.27/en-U ... pecifiers/
- jatingargrx
- Posts: 2
- Joined:
Re: Setting DataContext using Unreal C++ class
Thank you soo much. I totally missed it.The class must be marked as BlueprintType, since you want to use the result in blueprint:
https://docs.unrealengine.com/4.27/en-U ... pecifiers/
Code: Select all
UCLASS(Blueprintable)
Who is online
Users browsing this forum: No registered users and 94 guests