How to use slider in customer control
Posted: 10 Nov 2022, 16:12
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?