WPF TreeView Behaving strange

  • Thread starter Thread starter fatalerror0x00
  • Start date Start date
F

fatalerror0x00

Guest
Has anyone noticed UI Controls that sometimes don't appear how the Designer shows them to you. Here is my XAML code for my window so you can check it out and hopefully you'll see what I mean. If not then lucky you.


<Window x:Name="AddNASTT_Window" x:Class="Lead_Tool.NASTT_AddWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:HP_Lead_Tool" mc:Ignorable="d" Title="Lead Tool: NASTT - Add" Height="612" Width="1088" WindowStartupLocation="CenterOwner" FontFamily="Times New Roman" FontSize="16">

<Grid x:Name="AddNASTT_Grid">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<StatusBar Grid.ColumnSpan="4" Grid.Row="7" FontFamily="Times New Roman" FontSize="16">
<TextBlock>
<!--Informative Text will go here-->
</TextBlock>
</StatusBar>
<TreeView HorizontalAlignment="Left" Height="537" Margin="10,10,0,0" Grid.RowSpan="7" VerticalAlignment="Top" Width="250"/>

</Grid>

</Window>

This isn't the only time using WPF this has happened to me and not the only UI Control to do this but I feel I have to ask if anyone else sees what is so wrong with this. Pay attention to the Status Bar and Tree Views distance from each other when running and what it's set to in the Designer. The issue I see is I do not have the controls touching and even super close to touching they have what I'd call 10px between them according to the designer. Yet when running this window there is absolutely no more then 1px between them. The only work around I'm able to find it so center the vertical alignment.


I guess it's possible this is normal behavior of this and maybe other UI controls but I find this very strange and too different to just believe it was mad that way.

Update: I messed with it and completely broke the top and bottom borders of the control by changing the alignment even though it wasn't behind another control and so I deleted it and redid the control in a different manner and it's behaving completely normal now.

Continue reading...
 
Back
Top