There is a window with an inserted homemade component, which is blocked by something. As if some invisible zone on the side (shown by a yellow line), which overlaps it (similarly and below). If you resize the window, it moves.

bug

Window code next

<Window> <Grid> <Button x:Name="btnUpdate" Content="↻" Margin="10,10,0,0" Click="Button_Click_1" HorizontalAlignment="Left" Width="20" Height="20" VerticalAlignment="Top" /> <local:Clock x:Name="clock" Width="250" Height="250" Margin="10,10,72,33" HorizontalAlignment="Left" VerticalAlignment="Top" /> <Label x:Name="labelHours" Content="0 h." HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" FontSize="21.333" /> <Label x:Name="labelPass" Content="0 h." HorizontalAlignment="Left" Margin="10,0,0,10" VerticalAlignment="Bottom" FontSize="21.333" /> </Grid> </Window> 

The component itself has the following structure

 <UserControl> <Canvas Width="200" Height="200"> <!-- далее несколько внутренних canvas-ов --> <Canvas> <Path/> </Canvas> </Canvas> </UserControl> 

Who will tell you what the problem is, what is blocking it?

  • one
    And what do you have the dimensions and canvas are set and the clock in the window? remove the size designation in any one place. - Monk
  • Why do you need Margin with values ​​of type 72? You are not in WinForms, use the layout manager. Write Margin="10" . - VladD pm
  • @Monk Removed the task of the height of the component and let it go - Olexiy Logvinenko
  • @VladD there were a lot of experiments, and you are right - Oleksiy Logvinenko
  • @ OleksiyLogvinenko: Okay. In any case, it is better not to impose too many conditions, otherwise they may conflict. - VladD

1 answer 1

On the advice of comments removed the margin and setting the size of the component, which solved the problem.