Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Code: Select all
<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>
-
sfernandez
Site Admin
- Posts: 3152
- Joined:
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
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:
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:
Code: Select all
<Trigger Property="Button.IsPressed" Value="True">
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Hi,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:Code: Select all<Trigger Property="Button.IsPressed" Value="True">
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.
-
sfernandez
Site Admin
- Posts: 3152
- Joined:
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
What error are you getting in that case when the file is processed?I tested the Property="Button.IsPressed", and I found it can't work for me
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
Sorry for my expression,What error are you getting in that case when the file is processed?I tested the Property="Button.IsPressed", and I found it can't work for me
This is that the Property="Button.IsPressed" code has not error,
but it can't let the trigger work.
-
sfernandez
Site Admin
- Posts: 3152
- Joined:
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
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?
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
The trigger can't work when clicking button,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?
but it work when I click and drag using mouse.
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
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:
I just tested it and, with the Button.IsPressed workaround, everything seems to work for me:
Re: Button in ListBox's ItemTemplate, IsPressed Trigger can't work in UE4
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.
So the problem is that IsPressed Trigger can't work In ListBoxItem when touch down.
Very thanks.
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.
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
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