How to use slider in customer control
I use Noesis with UnrealEngine(5.0.3).
I hava a custom control:
SliderInput.xaml
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?
I hava a custom control:
SliderInput.xaml
Code: Select all
<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>
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?
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: How to use slider in customer control
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:
Can you check that?
Code: Select all
<controls:SliderInput Value="{Binding XXXX, Mode=TwoWay}" />
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 16 guests