Quantcast
Viewing all articles
Browse latest Browse all 18858

Wierd issue with button click event

Dear all,

I have a strange beaviour with a button click event.

I have a main windows which display a map( it could be anything else). The main windows is based on a main grid where controls gets align in. I have define in my case as a part of that main window a set of control that act like a bottom menu bar ( imagine a bottom menu bar on Windows 8 when you slide your finger from down to up) that I render visible when the user touch is finger at the range of 50 pixel from the bottom area. When hit the bottom bar appears with a set of button control.

In order to perform the visibility of the bottom menu bar I need to handle the PreviewMouseDown in order to identify touch position. that event is applied on my main grid and defined as follow :

 

private void _LayoutRoot_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
                          AppState.Instance.FingerPosition = e.Device.GetPosition(this);

                //check area of touch in order to show sysem commands
                if ((this.ActualWidth - AppState.Instance.FingerPosition.X) <= 50) ViewModelLocator.WorldMapViewModelStatic.ShowSystemCommandRight = true;
                else ViewModelLocator.WorldMapViewModelStatic.ShowSystemCommandRight = false;

                if (AppState.Instance.FingerPosition.X <= 50)  ViewModelLocator.WorldMapViewModelStatic.ShowSystemCommandLeft = true;
                else ViewModelLocator.WorldMapViewModelStatic.ShowSystemCommandLeft = false;

                //check area of touch in order to show bottom and top commands
                if ((this.ActualHeight - AppState.Instance.FingerPosition.Y) <= 50 || AppState.Instance.FingerPosition.Y <= 50)
                    ViewModelLocator.WorldMapViewModelStatic.ShowCommands = !ViewModelLocator.WorldMapViewModelStatic.ShowCommands && !ViewModelLocator.MainViewModelStatic.UserNotification.IsVisible;
                else ViewModelLocator.WorldMapViewModelStatic.ShowCommands = false;

                   }
The code above is doing nothing else than checking the touch position in order to show bottom bar menu with button set.

The button layout in the grid are defined as follow:

<Border Style="{StaticResource DynamicCommandBorder}" Grid.ColumnSpan="3" Grid.Row="2" Height="70" Background="Black" Visibility="{Binding Source={StaticResource Locator},Path=MainViewModel.IsSurfaceMode,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource BoolNotVisibilityConverter}}"><Grid><StackPanel x:Name="BottomCommand" Grid.ColumnSpan="3" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"
                    Visibility="{Binding Source={StaticResource Locator},Path=MainViewModel.AppInInactivityMode,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource BoolNotVisibilityConverter}}"><controls:MapButtonControl Margin="0,0,0,0" Tag="{Binding ElementName=BottomCommand,Path=Name}" DataContext="{Binding Source={StaticResource Locator}, Path=MapButtonsViewModel.MapModeButtons[0]}"/><controls:MapButtonControl Margin="20,0,0,0" Tag="{Binding ElementName=BottomCommand,Path=Name}" DataContext="{Binding Source={StaticResource Locator}, Path=MapButtonsViewModel.MapModeButtons[1]}"/><controls:MapButtonControl Margin="20,0,0,0" Tag="{Binding ElementName=BottomCommand,Path=Name}" DataContext="{Binding Source={StaticResource Locator}, Path=MapButtonsViewModel.MapModeButtons[2]}"/><Grid Margin="40,0,0,0"><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="Auto"/></Grid.RowDefinitions><Button x:Name="_buRotate2" Click="_buRotate2_Click"  Background="Black" ><Image RenderOptions.BitmapScalingMode="HighQuality" Width="25" Height="25" HorizontalAlignment="Center" Source="../Resources/Pictos/mapRotate.png"/></Button><TextBlock Grid.Row="1" Text="{Binding Source={x:Static props:Resources.Bu_MapRotateMode_Title}}" FontSize="10"  
                                   TextAlignment="Center" VerticalAlignment="Bottom" HorizontalAlignment="Center" 
                                   TextWrapping="Wrap"  
                                   Foreground="White" /></Grid></StackPanel><StackPanel x:Name="BottomsysCommand" Grid.ColumnSpan="3" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center"
                    Visibility="{Binding Source={StaticResource Locator},Path=MainViewModel.AppInInactivityMode,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource BoolNotVisibilityConverter}}"><controls:MapModeCommandContentControl Margin="40,0,0,0"/></StackPanel></Grid></Border>

The weird behavior I met here is that when I try to click on any button, none of the button events gets raised. If I remove the PreviewMouseDown event, all works fine.

What did I miss here ?

Thnaks for your help

regards 


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>