simsenVejle
Well-known member
- Joined
- Feb 14, 2021
- Messages
- 46
- Programming Experience
- Beginner
I'm totally new into WPF, so I hope for som help.
I have the image, which I have set to Grid.Row="1" Grid.Column="4" - The column is ok in the 5. position. But the row show up as in the bottom of row 4 as You can see on the picture. What I am doing wrong?
Best Regards
SimsenVejle
I have the image, which I have set to Grid.Row="1" Grid.Column="4" - The column is ok in the 5. position. But the row show up as in the bottom of row 4 as You can see on the picture. What I am doing wrong?
Best Regards
SimsenVejle
C#:
<Window x:Class="WPFDemo.MainWindow"
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:WPFDemo"
mc:Ignorable="d" FontFamily="Verdana" FontSize="16"
Title="Our WPF Demo" Height="481.204" Width="860.766">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" />
<!--Her er kanten så det ikke går helt ud til-->
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<!--* betyder at den tager resten af pladsen på formen-->
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<!--Samme som coulumns-->
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<!--Kun et tal ved margin fortæller at det er alle 4 marginer
1. tal er left, 2. tal er top, 3. tal er right og 4. er buttom-->
<TextBlock Grid.Column="1" Grid.Row="1" Text="WPF Super Demo"
FontSize="28" Grid.ColumnSpan="3" Margin="0,0,0,20" />
<TextBlock Grid.Column="1" Grid.Row="2" Text="First Name" />
<TextBox x:Name="txtFirstName" Grid.Column="2" Grid.Row="2" Width="150" />
<ComboBox x:Name="CmbMy" Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="2" Margin="10">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding FullName}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Button x:Name="BtnSubmit" Content="Run Me" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Margin="10" Click="BtnSubmit_Click" />
<Image MaxHeight="200" MaxWidth="200" Grid.Row="1" Grid.Column="4" Grid.RowSpan="6" Source="C:\3Billeder\20210131-01.jpg" />
</Grid>
</Window>