question

EmonHaque-1485 avatar image
0 Votes"
EmonHaque-1485 asked DaisyTian-1203 commented

How to get the padding of ListBoxItem and set it as the padding/Margin of Border/Grid?

These three (Plot, Space and Tenant) of Report Views use the same base LedgerView that contains Header, Entries and Footer sections:

98640-test.gif

Date, Particulars, ... are in Header, Total is in Footer and a ListBox in Entries section. The Header and Footers are aligned but the ListBoxItems are not, probably, because those ListBoxItems use some Padding by default. I want to get ListBoxItem's left and right padding and set those as the left/right padding of my Header and Footer in order to get everything aligned.

How to get that Padding?

EDIT


After some trials, looks like 5 in left/right padding makes it aligned properly. Is there anything in the SystemParameters or somewhere, I can get the value from?

windows-wpf
test.gif (2.3 MiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@EmonHaque-1485
If you know the Index of ListBoxItem, you could use below code to get the ListBoxItem:

  ListBoxItem item = (ListBoxItem)(lt.ItemContainerGenerator.ContainerFromIndex(0));

Then get the value pf Padding by below code:

  double left = item.Padding.Left;
  double top = item.Padding.Top;
  double right = item.Padding.Right;
  double buttom = item.Padding.Bottom;
1 Vote 1 ·

0 Answers