Button Click does not work if Button not in Canvas [SOLVED]

Please report bugs here. If you are unsure whether something is a bug or an expected behavior, please post it on the "Technical Support" forum instead, and wait for a moderator to handle/move the post.
Hey Ho
Posts: 5
Joined: Wed Aug 19, 2015 3:05 pm

Button Click does not work if Button not in Canvas [SOLVED]

Postby Hey Ho » Sat Sep 05, 2015 12:11 am

If u put a Button in a Grid and not into a Canvas the Click Event doesnt work

CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Re: Button Click does not work if Button not in Canvas

Postby CyborgDE » Sun Sep 06, 2015 5:00 am

I have the same Issue, please help urgent !!!

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Button Click does not work if Button not in Canvas

Postby JS-Support @Userware » Sun Sep 06, 2015 10:26 am

Hello,

Thanks for reporting this issue. It will be fixed in Beta 5, expected before the end of September.

Regards,
JS-Support

CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Re: Button Click does not work if Button not in Canvas

Postby CyborgDE » Sun Sep 06, 2015 10:16 pm

I need very fast a update / workaround!
I can not make any more tests, this is a very important funtion ...

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Button Click does not work if Button not in Canvas

Postby JS-Support @Userware » Sun Sep 06, 2015 11:27 pm

Hello,

The issue happens when multiple UI elements are contained inside a single Grid cell. In this case, the element that has the higher ZOrder takes all the mouse events. A workaround is to place only one element in each Grid cell. You can add columns and rows to ensure that the button has no other UI element with a higher ZOrder in the same cell.

Regards,
JS-Support

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Button Click does not work if Button not in Canvas

Postby JS-Support @Userware » Mon Sep 07, 2015 7:30 am

Hello again,

To ensure that your issue is properly fixed in the upcoming Beta 5, can you please post here the portion of your XAML code that doesn't work as expected, so that we can test it?

Thank you.

Regards,
JS-Support

CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Re: Button Click does not work if Button not in Canvas

Postby CyborgDE » Wed Sep 09, 2015 7:07 am

Hello,

this is my code. But you have to do something with the OnClick ...

Code: Select all

<fw:UserControl xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:fw="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:sys="clr-namespace:System;assembly=mscorlib"
     Width="300"
     Height="400"
     FontSize="11">
  <fw:Grid>
   <fw:Grid.ColumnDefinitions>
      <fw:ColumnDefinition With="*" />
   </fw:Grid.ColumnDefinitions>
   <fw:Grid.RowDefinitions>
      <fw:RowDefinition Height="*" />
      <fw:RowDefinition Height="Auto" />
   </fw:Grid.RowDefinitions>
    <fw:Button
      Grid.Column="0"
      Grid.Row="0"
      Content="Drück mich je ..."
      Margin="8,8,8,8"
      VerticalAlignment="Top"
      HorizontalAlignment="Left"
      Name="button1"
      fw:Click="{local:DoEvent Name=button1_Click, Typ=RoutedEventHandler}" />
    <fw:TextBox
      Name="TextBox1"
     Margin="100,8,8,8"
     VerticalAlignment="Top"
     HorizontalAlignment="Left"
      Text="Textbox"
      Height="28" />
  </fw:Grid>
</fw:UserControl>


If I put each control in it's own Grid, this does also not work !

Code: Select all

<fw:UserControl xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:fw="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:sys="clr-namespace:System;assembly=mscorlib"
     Width="300"
     Height="400"
     FontSize="11">
  <fw:Grid>
   <fw:Grid.ColumnDefinitions>
      <fw:ColumnDefinition With="*" />
   </fw:Grid.ColumnDefinitions>
   <fw:Grid.RowDefinitions>
      <fw:RowDefinition Height="*" />
      <fw:RowDefinition Height="Auto" />
   </fw:Grid.RowDefinitions>
  <fw:Grid>
    <fw:Button
      Grid.Column="0"
      Grid.Row="0"
      Content="Drück mich je ..."
      Margin="8,8,8,8"
      VerticalAlignment="Top"
      HorizontalAlignment="Left"
      Name="button1"
      fw:Click="{local:DoEvent Name=button1_Click, Typ=RoutedEventHandler}" />
  </fw:Grid>
  <fw:Grid>
    <fw:TextBox
      Name="TextBox1"
     Margin="100,8,8,8"
     VerticalAlignment="Top"
     HorizontalAlignment="Left"
      Text="Textbox"
      Height="28" />
  </fw:Grid>
  </fw:Grid>
</fw:UserControl>


Please Help !

Regards,
Uwe

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Button Click does not work if Button not in Canvas

Postby JS-Support @Userware » Wed Sep 16, 2015 8:15 am

Hello Uwe,

Sorry I was not very clear. The workaround that I suggested is not to place each object in its own Grid. It's to place its object in its own Grid cell. This means that, for the workaround to work, you need to place each object in a different row or in a different column.

Below is your code with some changes to fix the issue. Please notice how each element is in a different column.

XAML:

Code: Select all

<Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Button
            Grid.Column="0"
            Content="Drück mich je ..."
            Margin="8,8,8,8"
            VerticalAlignment="Top"
            HorizontalAlignment="Left"
            Name="button1"
            Click="button1_Click" />
        <TextBox
            Grid.Column="1"
            Name="TextBox1"
            Margin="100,8,8,8"
            VerticalAlignment="Top"
            HorizontalAlignment="Left"
            Text="Textbox"
            Height="28" />
    </Grid>


C#:

Code: Select all

void button1_Click(object sender, RoutedEventArgs e)
{
    MessageBox.Show("It works");
}


Thanks,
Regards,
JS-Support

CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Re: Button Click does not work if Button not in Canvas

Postby CyborgDE » Wed Sep 16, 2015 11:44 am

Hello,

thank you, this works.

When do you plan the relase of the Beta 5 ?

Regards, Uwe

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Button Click does not work if Button not in Canvas

Postby JS-Support @Userware » Wed Sep 30, 2015 9:17 am

Hello,

The Beta 5 version has now been released and the issue mentioned in this topic is supposed to be fixed. Please feel free to post here if you still encounter any related issues.

Thanks.
Regards,
JS-Support


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 23 guests

 

 

cron