Create a menu setting popup with a slider inside ContentControl
Posted: 01 Jun 2022, 11:15
I'm creating a slider that modifies a variable inside unreal engine by using onewaytosource binding mode (changing volume setting for example). Now I need to create an event that triggered when the value changed but I'm having a hard time doing.
I have a Popup element with a ContentControl child that has the property Style asign to a Style that has the Slider. Something like this
The popup is enabled when a button is pressed. When changing the slider will change the "VolumeMaster" in unreal. I'm having trouble binding the ValueChanged property of Slider to an event so I'd like to ask how to correctly bind this property when I'm at the UserControl root element (in blueprint and c++ if possible). The intention was to create a function (blueprint) with the name "OnMasterVolumeChanged" to print the current value of Slider. Tried using FindName to search for the slider but failed. I would like to be able to bind the function without changing the above structure if possible.
Can anyone guide me to the right direction. I'm only a beginner in xaml/wpf so any pointer would be appreciated.
I have a Popup element with a ContentControl child that has the property Style asign to a Style that has the Slider. Something like this
Code: Select all
<UserControl x:Class="MyNameSpace.Home" ...>
<UserControl.Resources>
<ControlTemplate x:Key="Template.ItemToolTip" TargetType="{x:Type ContentControl}">
<Grid>
<StackPanel Orientation="Horizontal" Margin="0,10,0,10" HorizontalAlignment="Stretch">
<TextBlock Text="Volume: "/>
<Slider x:Name="MasterVolume" Margin="0,10,0,10" Width="270" Value="{Binding MasterVolume, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}" ValueChanged="{Binding OnMasterVolumeChanged}">
</Slider>
</StackPanel>
</Grid>
</ControlTemplate>
<Style x:Key="Style.ItemToolTip" TargetType="{x:Type ContentControl}">
<Setter Property="Template" Value="{StaticResource Template.ItemToolTip}"/>
</Style>
</UserControl.Resources>
<Grid>
<Popup IsOpen="{Binding IsChecked, ElementName=MenuButton}" x:Name="Popup" StaysOpen="False" AllowsTransparency="True" Placement="RelativePoint" PlacementTarget="{Binding ElementName=PopupPosition}">
<ContentControl x:Name="MenuPopup" Style="{StaticResource Style.ItemToolTip}"/>
</Popup>
</Grid>
</UserControl>
Can anyone guide me to the right direction. I'm only a beginner in xaml/wpf so any pointer would be appreciated.