Page 1 of 1

How to use slider in customer control

Posted: 10 Nov 2022, 16:12
by endink
I use Noesis with UnrealEngine(5.0.3).

I hava a custom control:

SliderInput.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
                     xmlns:local="clr-namespace:UI.Controls">
    <Style TargetType="{x:Type local:SliderInput}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:SliderInput}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Slider 
                                x:Name="INNER_SLIDER"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Center"
                                Value="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                                TickFrequency="{TemplateBinding TickFrequency}"
                                Minimum="{TemplateBinding Minimum}" 
                                Maximum="{TemplateBinding Maximum}" 
                                SmallChange="{TemplateBinding SmallChange}"
                                LargeChange="{TemplateBinding LargeChange}"
                                >
                            </Slider>
                            <TextBlock  Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="7 0 0 0"
                                Visibility="{TemplateBinding ValueVisible,  Converter={StaticResource BooleanToVisibilityConverter}}"  
                                               Text="{Binding Value, ElementName=INNER_SLIDER, StringFormat={}{0:F} }" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
c++ code behind is no broblem, It inherits from Control and defines a float dependency property named "Value".

when I use SliderInput:

<controls:SliderInput Value="{Binding XXXX}" />

XXX is a UPROPERTY with BlueprintReadWrite on a UObject

It seems that XXX is always OneWay binding, In other words, when I slide the slider in UI, the slider doesn't change the XXX value,how to make SliderInput bind XXX with two way?

Re: How to use slider in customer control

Posted: 11 Nov 2022, 16:33
by sfernandez
You are binding the Blueprint property to the Value property of your SliderInput without any more parameters. How are you defining that dependency property? Is it registered with the FrameworkPropertyMetadataOptions_BindsTwoWayByDefault flag? Otherwise you have to explicitly set the binding mode to TwoWay:
<controls:SliderInput Value="{Binding XXXX, Mode=TwoWay}" />
Can you check that?