Page 1 of 1

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

Posted: Sat Sep 05, 2015 12:11 am
by Hey Ho
If u put a Button in a Grid and not into a Canvas the Click Event doesnt work

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

Posted: Sun Sep 06, 2015 5:00 am
by CyborgDE
I have the same Issue, please help urgent !!!

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

Posted: Sun Sep 06, 2015 10:26 am
by JS-Support @Userware
Hello,

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

Regards,
JS-Support

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

Posted: Sun Sep 06, 2015 10:16 pm
by CyborgDE
I need very fast a update / workaround!
I can not make any more tests, this is a very important funtion ...

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

Posted: Sun Sep 06, 2015 11:27 pm
by JS-Support @Userware
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

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

Posted: Mon Sep 07, 2015 7:30 am
by JS-Support @Userware
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

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

Posted: Wed Sep 09, 2015 7:07 am
by CyborgDE
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

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

Posted: Wed Sep 16, 2015 8:15 am
by JS-Support @Userware
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

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

Posted: Wed Sep 16, 2015 11:44 am
by CyborgDE
Hello,

thank you, this works.

When do you plan the relase of the Beta 5 ?

Regards, Uwe

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

Posted: Wed Sep 30, 2015 9:17 am
by JS-Support @Userware
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