Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Padded textblock with new row on grid wpf. I have 5x5 grid means array is 0 to 4 for row as it is column.

C#
TextBlock TB = new TextBlock();
TB.Text = "Too long long long long text....";
Grid.Children.Add(TB);


What I have tried:

I tried SetColumn and SetRow function but it should start from left.
Posted
Updated 12-Sep-20 6:59am
Comments
Sandeep Mewara 12-Sep-20 9:47am    
Can you please rephrase or try again about what you are trying exactly?
Member 13310481 12-Sep-20 9:54am    
Here is simple image that i want get https://i.ibb.co/89V3gcd/Untitled.png
Sandeep Mewara 12-Sep-20 9:57am    
Looks like you need to assign specific column and row for the textblock in the designed grid layout and that should be good enough.

Apply rowspan or column span as per your UI need.
[no name] 12-Sep-20 11:47am    
Do it in XAML first; then you'll know what works in code.

1 solution

The styling should be done in XAML (including putting a textblock into a grid cell) That way, all you have to do on the backend is populate the deisplayed data.

Grid objects are usually responsible for controlling whether a column is wrapped or not. So properly designing your grid is your only viable course of action.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900