Binding to Thumb.DragStarted event in Unity + NoesisGUI
Hey, we are trying to bind to the Thumb.DragStarted event so we can know when the user starts dragging a slider. Here’s our XAML and Code Behind:
XAML:
Code Behind:
This code runs in a pure C# WPF app. But when we run in Unity using NoesisGUI, we get the following error:
However, this then results in the following new error:
XAML:
Code: Select all
<Slider Thumb.DragStarted="Slider_DragStarted" Width="200" VerticalAlignment="Center" Maximum="100" SmallChange="1" LargeChange="10" Value="{Binding SliderValue}" Margin="187.5,13.011,412.5,418.989"/>
Code: Select all
private void Slider_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
{
// Debug.Log("Drag started");
}
We are able to avoid this error by changing the Slider_DragStarted method to:The type or namespace name `Controls' does not exist in the namespace` System.Windows'. Are you missing an assembly reference?
Code: Select all
private void Slider_DragStarted(object sender, object e)
{
// Debug.Log("Drag started");
}
Do you have any recommendations on what we might be doing wrong here?NoesisException: Assets/UI/PlayerControls.xaml(11): 'KMotionMVVM.PlayerControls' does not contain a definition for 'Slider_DragStarted’
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Binding to Thumb.DragStarted event in Unity + NoesisGUI
Hi,
With current C# API is not possible yet to register against attached events because RoutedEvents are not exposed neither are UIElement.AddHandler/RemoveHandler.
Could you please add a request in our bugtracker for this?
The option you have now is to assign a name to the Slider and in your user control's Loaded event search for the slider's Thumb (inside the template).
Sorry for the inconveniences.
With current C# API is not possible yet to register against attached events because RoutedEvents are not exposed neither are UIElement.AddHandler/RemoveHandler.
Could you please add a request in our bugtracker for this?
The option you have now is to assign a name to the Slider and in your user control's Loaded event search for the slider's Thumb (inside the template).
Code: Select all
public MyUserControl()
{
Loaded += OnLoaded;
InitializeComponent();
}
void OnLoaded()
{
Slider slider = (Slider)FindName("Slider");
Thumb thumb = (Thumb)slider.GetTemplateChild("SliderThumb");
thumb.DragStarted += Slider_DragStarted;
}
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 12 guests