Page 1 of 2
Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Posted: 28 Mar 2018, 06:19
by ride_wind
<UserControl.Resources>
<Style x:Key="ListBoxTestStyle" TargetType="ListBox">
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Grid>
<Button Width="100" Height="30" Margin="10">
<Button.Template>
<ControlTemplate TargetType="Button">
<Border x:Name="Bg" Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Background="Red"/>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="Bg" Property="Background" Value="Green"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
<!-- Other controls-->
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<ListBox ItemsSource="{Binding ListSource}" Width="300" Height="300"
Style="{StaticResource ListBoxTestStyle}"/>
</Grid>
This is my xaml code, it work well in WPF, but can't work in UE4.
- WPF.gif (8.07 KiB) Viewed 3733 times
- UE4.gif (15.68 KiB) Viewed 3733 times
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Posted: 28 Mar 2018, 11:40
by sfernandez
It seems to be a bug when trying to solve Trigger.Property owner type in this case, and is not able to associate it with the Button (it should know that from the ControlTemplate.TargetType).
Could you please create a ticket in our bugtracker?
Meanwhile you can just explicitily set the property owner in the trigger to avoid the bug:
<Trigger Property="Button.IsPressed" Value="True">
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Posted: 02 Apr 2018, 05:55
by ride_wind
It seems to be a bug when trying to solve Trigger.Property owner type in this case, and is not able to associate it with the Button (it should know that from the ControlTemplate.TargetType).
Could you please create a ticket in our bugtracker?
Meanwhile you can just explicitily set the property owner in the trigger to avoid the bug:
<Trigger Property="Button.IsPressed" Value="True">
Hi,
I tested the
Property="Button.IsPressed", and I found it can't work for me,
But the IsPressed trigger work when I use mouse click and drag.
I reported it in bugtracker,
Thanks.
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Posted: 02 Apr 2018, 16:46
by sfernandez
I tested the Property="Button.IsPressed", and I found it can't work for me
What error are you getting in that case when the file is processed?
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Posted: 03 Apr 2018, 05:03
by ride_wind
I tested the Property="Button.IsPressed", and I found it can't work for me
What error are you getting in that case when the file is processed?
Sorry for my expression,
This is that the Property="Button.IsPressed" code has not error,
but it can't let the trigger work.
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Posted: 03 Apr 2018, 12:52
by sfernandez
It is strange, I was able to reproduce the parsing error using your xaml, and if I change the trigger property to "Button.IsPressed" I get no error and trigger is working fine.
In what situation does not work for you? Does the trigger work when clicking the button using the mouse?
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Posted: 03 Apr 2018, 14:09
by ride_wind
It is strange, I was able to reproduce the parsing error using your xaml, and if I change the trigger property to "Button.IsPressed" I get no error and trigger is working fine.
In what situation does not work for you? Does the trigger work when clicking the button using the mouse?
The trigger can't work when clicking button,
but it work when I click and drag using mouse.
- ListBoxTest.gif (130.64 KiB) Viewed 3668 times
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Posted: 07 Apr 2018, 13:50
by hcpizzi
I'm sorry it took so long to get back to you.
I just tested it and, with the Button.IsPressed workaround, everything seems to work for me:
- IsPressed.gif (21.08 KiB) Viewed 3598 times
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Posted: 17 Apr 2018, 09:40
by ride_wind
Hi hcpizzi,
I found the reason why the Ispressed can't work in my project,
Bacause I opened the UseMouseForTouch setting. It can work In window Platform, but can't work in Mobile, if I close the setting.
- MouseForTouch.png (8.06 KiB) Viewed 3381 times
So the problem is that IsPressed Trigger can't work In ListBoxItem when touch down.
Very thanks.
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Posted: 17 Apr 2018, 10:54
by hcpizzi
I'm glad you figured it out. I didn't think of that, it's good to know.