So you're trying to say that it's not possible with only a Grid?
I wasn't trying to state it as a fact, I just meant that I can't understand
at all how it could be done, I'm specifically talking about the "wrapping", with a wrappanel it's obvious and simple, with a grid I'm still at a total loss, even with the help you've given so far (I'm beginning to feel like I'm being annoying by not getting this). If I imagine attempting what you describe, I have my textblocks (I've been calling them labels this whole time) each set to their appropriate row/column, this is brick wall I can't get passed, they would have to move, how could they ever move to a different cell?
Your current problem is your lack of experience with Xaml code. But don't take that as me judging you, as I'm not. I admire your willingness to buy a book on WPF alone, then to further teach yourself, by dabbling with the various controls to try and achieve a very simple task. That's actually rude of me, since any task is easy when you know how to approach it. Whereas; in my case, I've spent the better part of my later career and life learning as much WPF as I could. So, this is actually all very boring for me, as it is only basic Xaml, and basic structuring. Of course, you're only partly there, since you have yet to write your code for the various layout to be altered when your user decides to do his clicky thing and add more controls, and for each control, you need more <Grid.ColumnDefinitions>
and <Grid.RowDefinitions>
, and once they are created, you would add more labels etc. It's not something I will be doing for you, as its time consuming, and time I'd rather not waste doing it for you. It's a learning experience for you too, so play with what I gave you.
Have a good night.
When people are teaching me things I never take anything personally or as a judgement, I know I'm failing at the most basic things, and self learning is a struggle. I'm just grateful for any time given to trying to help this floundering noob.
I looked at the code you posted and ran it in VS. I understand what you've written, I just don't see how any wrapping could come of it since it's in a grid. I'm not trying to say that you're wrong, obviously you're the one who knows, not me, it's just that unless I see a grid do that or something I don't know if I can believe it. In your code there are three columns, how much more code do you think it would take to get those columns to wrap if the window size is reduced enough? Can you give me some hints on that one specific aspect, it's the only thing I'm not understanding, the wrapping part.
This is the one and only time I've come across something that I can't begin to even try to attempt. I feel like there is some key piece of information I'm missing that is making this seem absolutely impossible to such an extent It makes me wonder if I've been unclear and given you a false impression of what I'm going for. So, just to make sure and be absolutely crystal clear would you mind pasting the code below into your IDE, running the app and confirming that the behaviour you see when resizing the window can be done with a grid alone, if so, it makes me wonder why the wrappanel would ever be used over the grid (well, it's easier for us noobs I guess).
<Window x:Class="WpfApp1.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:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Width="510" Height="300" Background="#FF191919" Foreground="LightSlateGray" WindowStartupLocation="CenterScreen" >
<WrapPanel Grid.Row="3"
Grid.Column="1"
Grid.ColumnSpan="3"
HorizontalAlignment="Center">
<Grid Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
<Grid Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28" />
</Grid>
<Grid Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
<Grid Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum Lorem" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
<Grid Margin="0 5" Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
<Grid Margin="0 5" Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum Lorem" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
<Grid Margin="0 5" Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum Lorem" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
<Grid Margin="0 5" Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum Lorem" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
<Grid Margin="0 5" Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum Lorem" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
<Grid Margin="0 5" Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum Lorem" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
<Grid Margin="0 5" Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
<Grid Margin="0 5" Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum Lorem" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
<Grid Margin="0 5" Height="75" Width="100">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
<Grid Margin="0 5" Height="75" Width="100" >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" Text="LoremIpsum Lorem" TextDecorations="Underline" HorizontalAlignment="Center" FontSize="14" FontFamily="Georgia"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="0" HorizontalAlignment="Center" FontSize="28"/>
</Grid>
</WrapPanel>
</Window>
@glasswizzard :
In your screenshots in post #7, you had some items which have two lines of text. Is the two lines of text intentional, or are they the result of a long line of text that gets line wrapped to two lines because you've setup a specific width for each item?
Both, I have a width and height set for each one which gives me the a limit for the length of each line to prevent them from becoming too long.
Are widths of all the items the same?
Yes, width and height are the same, you can see it in the code above.
If they are all the same, is that something you hardcoded, or is it computed somehow?
I hardcoded it, I figured out the right size to get everything neat and set them all to it.
For the two line line wrapped items, did you decide on whether you wanted the text flush to the top, flush to the bottom just above the number, or centered between the top and the number?
I managed to get them to look like the below image, which is perfect.