ride_wind
Topic Author
Posts: 34
Joined: 07 Feb 2018, 03:33

Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4

28 Mar 2018, 06:19

<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
WPF.gif (8.07 KiB) Viewed 3656 times
UE4.gif
UE4.gif (15.68 KiB) Viewed 3656 times
 
User avatar
sfernandez
Site Admin
Posts: 3152
Joined: 22 Dec 2011, 19:20

Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4

28 Mar 2018, 11:40

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">
 
ride_wind
Topic Author
Posts: 34
Joined: 07 Feb 2018, 03:33

Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4

02 Apr 2018, 05:55

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.
 
User avatar
sfernandez
Site Admin
Posts: 3152
Joined: 22 Dec 2011, 19:20

Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4

02 Apr 2018, 16:46

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?
 
ride_wind
Topic Author
Posts: 34
Joined: 07 Feb 2018, 03:33

Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4

03 Apr 2018, 05:03

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.
 
User avatar
sfernandez
Site Admin
Posts: 3152
Joined: 22 Dec 2011, 19:20

Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4

03 Apr 2018, 12:52

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?
 
ride_wind
Topic Author
Posts: 34
Joined: 07 Feb 2018, 03:33

Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4

03 Apr 2018, 14:09

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
ListBoxTest.gif (130.64 KiB) Viewed 3591 times
 
User avatar
hcpizzi
Site Admin
Posts: 342
Joined: 09 Feb 2012, 12:40

Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4

07 Apr 2018, 13:50

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
IsPressed.gif (21.08 KiB) Viewed 3521 times
 
ride_wind
Topic Author
Posts: 34
Joined: 07 Feb 2018, 03:33

Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4

17 Apr 2018, 09:40

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
MouseForTouch.png (8.06 KiB) Viewed 3304 times
So the problem is that IsPressed Trigger can't work In ListBoxItem when touch down.

Very thanks.
 
User avatar
hcpizzi
Site Admin
Posts: 342
Joined: 09 Feb 2012, 12:40

Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4

17 Apr 2018, 10:54

I'm glad you figured it out. I didn't think of that, it's good to know.

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 0 guests