shiaro007
Topic Author
Posts: 14
Joined: 08 Dec 2018, 07:50

Slider control: Print the slider value at the same time when sliding??

20 Dec 2018, 20:46

Hi, i'm using NoesisGUI for unreal and I'm trying to use a slider control in my XAML file.
What I want is to continously use the value of a slider(say..print string) when I'm changing the value.
I tried by using "ValueChanged" to create a binding SliderChanged and created the same named function in my NoesisView in unreal, but it does not work.
<Slider HorizontalAlignment="Left" Margin="84,80,0,0" VerticalAlignment="Top" Height="40" Width="191" Value="{Binding XValue, Mode=OneWayToSource} ValueChanged="{Binding SliderChanged}"/>

The same works for a button if I use its "Command" property for binding.

Is there anything I'm missing here?

Tags:
 
User avatar
hcpizzi
Site Admin
Posts: 206
Joined: 09 Feb 2012, 12:40

Re: Slider control: Print the slider value at the same time when sliding??

21 Dec 2018, 12:11

Hi shiaro007,

ValueChanged in a Slider is an event, and an event cannot be set to a Binding in XAML. Command in a button, on the other hand, is a DependencyProperty of type ICommand, that can be set to a Binding.

However, you can use our EventToCommand class in Noesis SDK 2.1 to achieve what you want like this:
<Grid
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    xmlns:noesis="clr-namespace:NoesisGUIExtensions">
    <Slider Value="{Binding Value}" noesis:EventToCommand.Event="ValueChanged" noesis:EventToCommand.Command="{Binding ValueChanged}"/>
</Grid>
Please, take into account that this will be superseded on version 2.2 by the more powerful functionality in the Interactivity framework. After version 2.2 you will be able to do the same with the following XAML:
<Grid
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions">
    <Slider Value="{Binding Value}">
        <i:Interaction.Triggers>
            <ei:EventTrigger EventName="ValueChanged">
                <i:InvokeCommandAction Command="{Binding ValueChanged}"/>
            </ei:EventTrigger>
        </i:Interaction.Triggers>
    </Slider>
</Grid>
I've attached a small Blueprint only sample that shows how to do it.
Slider.zip
(12.55 KiB) Downloaded 11 times

Who is online

Users browsing this forum: danilopezf10 and 2 guests