locked
Need to focus the grid which placed inside the Scroll Viewer on Mouse Click RRS feed

  • Question

  • Problem 1:

     

    I need to focus the Grid(UI Element) when it is placed inside the Scroll viewer.

    Code:
    ```
      <ScrollViewer>
            <Grid x:Name="RootGrid">
                <Border 
                        Height="24"
                        Width="300"
                        Focusable="True"
                        Background="White"
                        BorderBrush="Silver"
                        BorderThickness="1"
                        SnapsToDevicePixels="True">
                    <Grid Background="Red" Focusable="True" x:Name="ViewGrid">
                    </Grid>
                </Border>
            </Grid>
        </ScrollViewer>
    ```


    Problem Faced:

    1.When I click the above control, scroll viewer is the focused element but i need Grid element needs to focused.
    Please suggest solution to fix this.

    Problem 2:

    I have custom control. There is an unwanted white space was shown between border and grid in higher scaling like 125, 150 etc.,

    Code

    ```
          <Grid x:Name="RootGrid">
                <Border 
                        Height="24"
                        Width="300"
                        Focusable="True"
                        Background="White"
                        BorderBrush="Silver"
                        BorderThickness="1"
                        SnapsToDevicePixels="True">
                    <Grid Background="Red" Focusable="True" x:Name="ViewGrid">
                    </Grid>
                </Border>
            </Grid>
        </ScrollViewer
    ```
    Image:





    Please suggest solution to resolve this.


    • Moved by CoolDadTx Thursday, April 16, 2020 1:34 PM WPF related
    Thursday, April 16, 2020 12:44 PM

All replies

  • This forum is for C# specific questions only. Your question appears to be related to WPF. Please post over in their new forum.

    Michael Taylor http://www.michaeltaylorp3.net

    Thursday, April 16, 2020 1:34 PM