{"id":273112,"date":"2016-01-28T14:05:03","date_gmt":"2016-01-28T11:05:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=273112"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=273112","title":{"rendered":"\u0424\u0438\u0448\u043a\u0438 XAML-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430: \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 Grid"},"content":{"rendered":"<p>       \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0443\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430 <i>Grid<\/i>.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/741\/5d8\/8d1\/7415d88d178848f6a1c93df00c75657c.jpg\" alt=\"image\"\/><a name=\"habracut\"><\/a><br \/>  \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <i>Grid<\/i> \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/p>\n<pre><code class=\"xml\">&lt;Grid&gt;     &lt;Grid.RowDefinitions&gt;         &lt;RowDefinition Height=&quot;*&quot;\/&gt;         &lt;RowDefinition MinHeight=&quot;20&quot; Height=&quot;Auto&quot;\/&gt;         &lt;RowDefinition Height=&quot;*&quot;\/&gt;         &lt;RowDefinition Height=&quot;2*&quot;\/&gt;         &lt;RowDefinition Height=&quot;*&quot; MaxHeight=&quot;100&quot;\/&gt;         &lt;RowDefinition Height=&quot;*&quot;\/&gt;         &lt;RowDefinition Height=&quot;*&quot;\/&gt;     &lt;\/Grid.RowDefinitions&gt;          &lt;Grid.ColumnDefinitions&gt;         &lt;ColumnDefinition Width=&quot;*&quot;\/&gt;         &lt;ColumnDefinition MinWidth=&quot;100&quot; Width=&quot;*&quot; MaxWidth=&quot;300&quot;\/&gt;         &lt;ColumnDefinition Width=&quot;*&quot;\/&gt;     &lt;\/Grid.ColumnDefinitions&gt;          &lt;TextBlock     \tGrid.Row=&quot;1&quot;     \tGrid.Column=&quot;1&quot;     \tGrid.RowSpan=&quot;1&quot;     \tGrid.ColumnSpan=&quot;2&quot;&gt;     \t     &lt;!--...--&gt; &lt;\/Grid&gt; <\/code><\/pre>\n<p>  \u0423 \u043d\u0435\u0433\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0440\u044f\u0434 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432:<br \/>  1. \u041f\u0430\u0434\u0435\u043d\u0438\u0435 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430 \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430<br \/>  2. \u0421\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u043f\u0440\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 c\u043c\u0435\u043d\u0435 \u0442\u0438\u043f\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430 \u0441 <i>Grid<\/i> \u043d\u0430 <i>StackPanel<\/i>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u043b\u0438\u0431\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043b\u043e\u043a\u0438 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0434\u043e\u0431\u043d\u043e<br \/>  3. \u0422\u0430\u043a\u043e\u0439 <i>Grid<\/i> \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u043d \u0438 \u0432\u0438\u0434\u043e\u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0441\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043f\u043e\u0434\u0440\u0443\u0447\u043d\u043e \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 <i>MVVM<\/i><\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0435\u0441\u044c\u043c\u0430 \u043e\u0441\u0442\u0440\u043e\u0443\u043c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432. \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 <i>Rack (\u0440\u0443\u0441\u043a. \u00ab\u0421\u0442\u0435\u043b\u043b\u0430\u0436\u00bb)<\/i><\/p>\n<pre><code class=\"xml\">&lt;Grid Rack.Rows=&quot;* 20\\Auto * 2* *\/100 * *&quot; Rack.Columns=&quot;* 50\\*\/100 *&quot;&gt;     &lt;TextBlock Rack.Set=&quot;R1 C1 RS1 CS2&quot;&gt;     &lt;!--...--&gt; &lt;\/Grid&gt; <\/code><\/pre>\n<p>  1. \u041a\u043e\u0434 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u0435\u043d<br \/>  2. \u041f\u0440\u0438 \u0437\u0430\u043c\u0435\u043d\u0435 \u0442\u0438\u043f\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c<br \/>  3. \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430<\/p>\n<pre><code class=\"xml\">&lt;Grid      Rack.Rows=&quot;{Binding Property1, Converter={StaticResource RowsConverter}}&quot;      Rack.Columns=&quot;{Binding Property1, Converter={StaticResource ColumnsConverter}}&quot; &gt;          &lt;TextBlock Rack.Set=&quot;{Binding Property1, Converter={StaticResource TextPositionConverter}}&quot;&gt;     &lt;!--...--&gt; &lt;\/Grid&gt; <\/code><\/pre>\n<p>  \u041f\u043e \u043d\u0430\u0447\u0430\u043b\u0443 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e, \u043d\u043e \u043d\u0430 \u0434\u0435\u043b\u0435 \u043e\u043d \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c, \u0441\u043a\u0430\u0436\u0435\u043c, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438 \u0434\u043b\u044f <i>Path<\/i>. \u0412 \u0441\u0442\u0440\u043e\u043a\u0435 [<i>Rack.Rows=&quot;* 20\\Auto * 2* *\/100 * *&quot;<\/i>] \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0431\u0435\u043b \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043b\u043e\u043d\u043e\u043a [\u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432], \u0430 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <i>\u00ab20\\\u00bb<\/i> \u0438 <i>\u00ab\/100\u00bb<\/i> \u0437\u0430\u0434\u0430\u044e\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c [<i>Rack.Set=\u00abR1 C1 RS1 CS2\u00bb<\/i>] \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c <i>Grid.Row<\/i>, <i>Grid.Column<\/i>, <i>Grid.RowSpan<\/i>, <i>Grid.ColumnSpan<\/i>, \u043f\u0440\u0438\u0447\u0451\u043c \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0442\u043e \u0435\u0441\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c [<i>Rack.Set=\u00abR1 C1\u00bb<\/i>] \u0442\u0430\u043a\u0436\u0435 \u0432\u0435\u0440\u043d\u0430.<\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 (<i>atteched properties<\/i>) \u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"http:\/\/makeloft.by\/ru\/tools\"><i>Aero Framework<\/i><\/a>. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u0442\u043a\u0440\u044b\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u0442\u043e \u0432\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u043e\u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e. \u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043a\u0430\u0447\u0430\u0435\u0442\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 <i>HelloAero<\/i>, \u0442\u043e \u0432\u043e\u043e\u0447\u0438\u044e \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u043a\u0430\u043a\u0438\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u043d\u044b\u043c \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <i>Grid<\/i> \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438. \u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0430\u0440\u0443 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u043e\u0432 \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0438\u0436\u0435.<\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0412\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Screenshots<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/8bc\/9f3\/c4f\/8bc9f3c4f82f470aa0b8a7e7615651aa.png\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/127\/305\/e55\/127305e559f1491c8249116bb99aa12d.png\"\/>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Source Code<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>using System; using System.Diagnostics; using System.Linq; using System.Windows; using System.Windows.Controls;  namespace Aero.Markup {     public static class Rack     {         #region Declarations          public static readonly DependencyProperty ShowLinesProperty = DependencyProperty.RegisterAttached(             &quot;ShowLines&quot;, typeof (bool), typeof (Rack), new PropertyMetadata(default(bool), (o, args) =&gt;             {                 var grid = o as Grid;                 if (grid == null) return;                 grid.ShowGridLines = Equals(args.NewValue, true);             }));          public static void SetShowLines(DependencyObject element, bool value)         {             element.SetValue(ShowLinesProperty, value);         }          public static bool GetShowLines(DependencyObject element)         {             return (bool) element.GetValue(ShowLinesProperty);         }          public static readonly DependencyProperty RowsProperty = DependencyProperty.RegisterAttached(             &quot;Rows&quot;, typeof (string), typeof (Rack), new PropertyMetadata(&quot;&quot;, OnRowsPropertyChanged));          public static readonly DependencyProperty ColumnsProperty = DependencyProperty.RegisterAttached(             &quot;Columns&quot;, typeof (string), typeof (Rack), new PropertyMetadata(&quot;&quot;, OnColumnsPropertyChanged));          public static string GetRows(DependencyObject d)         {             return (string) d.GetValue(RowsProperty);         }          public static void SetRows(DependencyObject d, string value)         {             d.SetValue(RowsProperty, value);         }          public static string GetColumns(DependencyObject d)         {             return (string) d.GetValue(ColumnsProperty);         }          public static void SetColumns(DependencyObject d, string value)         {             d.SetValue(ColumnsProperty, value);         }          public static readonly DependencyProperty SetProperty = DependencyProperty.RegisterAttached(             &quot;Set&quot;, typeof (string), typeof (Rack), new PropertyMetadata(&quot;&quot;, OnSetChangedCallback));          public static void SetSet(DependencyObject element, string value)         {             element.SetValue(SetProperty, value);         }          public static string GetSet(DependencyObject element)         {             return (string) element.GetValue(SetProperty);         }          #endregion          private static void OnRowsPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)         {             var grid = o as Grid;             if (grid == null) return;              grid.RowDefinitions.Clear();             var patterns = (e.NewValue as string ?? &quot;&quot;).Split(new[] {' ', ','}, StringSplitOptions.RemoveEmptyEntries);             foreach (var pattern in patterns)             {                 var indexMin = pattern.IndexOf(@&quot;\\&quot;, StringComparison.Ordinal);                 var indexMax = pattern.IndexOf(@&quot;\/&quot;, StringComparison.Ordinal);                 var hasMin = indexMin &gt;= 0;                 var hasMax = indexMax &gt;= 0;                 var valueMin = hasMin ? pattern.Substring(0, indexMin) : &quot;&quot;;                 var valueMax = hasMax ? pattern.Substring(indexMax + 1, pattern.Length - indexMax - 1) : &quot;&quot;;                 var start = hasMin ? indexMin + 1 : 0;                 var finish = hasMax ? indexMax : pattern.Length;                 var value = pattern.Substring(start, finish - start);                 var definition = new RowDefinition {Height = value.ToGridLength()};                 if (valueMin != &quot;&quot;) definition.MinHeight = double.Parse(valueMin);                 if (valueMax != &quot;&quot;) definition.MaxHeight = double.Parse(valueMax);                 grid.RowDefinitions.Add(definition);             }         }          private static void OnColumnsPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)         {             var grid = o as Grid;             if (grid == null) return;              grid.ColumnDefinitions.Clear();             var patterns = (e.NewValue as string ?? &quot;&quot;).Split(new[] {' ', ','}, StringSplitOptions.RemoveEmptyEntries);             foreach (var pattern in patterns)             {                 var indexMin = pattern.IndexOf(@&quot;\\&quot;, StringComparison.Ordinal);                 var indexMax = pattern.IndexOf(@&quot;\/&quot;, StringComparison.Ordinal);                 var hasMin = indexMin &gt;= 0;                 var hasMax = indexMax &gt;= 0;                 var valueMin = hasMin ? pattern.Substring(0, indexMin) : &quot;&quot;;                 var valueMax = hasMax ? pattern.Substring(indexMax + 1, pattern.Length - indexMax - 1) : &quot;&quot;;                 var start = hasMin ? indexMin + 1 : 0;                 var finish = hasMax ? indexMax : pattern.Length;                 var value = pattern.Substring(start, finish - start);                 var definition = new ColumnDefinition {Width = value.ToGridLength()};                 if (valueMin != &quot;&quot;) definition.MinWidth = double.Parse(valueMin);                 if (valueMax != &quot;&quot;) definition.MaxWidth = double.Parse(valueMax);                 grid.ColumnDefinitions.Add(definition);             }         }          private static void OnSetChangedCallback(DependencyObject o, DependencyPropertyChangedEventArgs e)         {             var element = o as FrameworkElement;             if (element == null) return;             var patterns = (e.NewValue as string ?? &quot;&quot;).Split(new[] {' ', ','}, StringSplitOptions.RemoveEmptyEntries);             var columnPattern = patterns.FirstOrDefault(p =&gt; p.StartsWith(&quot;C&quot;) && !p.StartsWith(&quot;CS&quot;)).With(p =&gt; p.Replace(&quot;C&quot;, &quot;&quot;));             var rowPattern = patterns.FirstOrDefault(p =&gt; p.StartsWith(&quot;R&quot;) && !p.StartsWith(&quot;RS&quot;)).With(p =&gt; p.Replace(&quot;R&quot;, &quot;&quot;));             var columnSpanPattern = patterns.FirstOrDefault(p =&gt; p.StartsWith(&quot;CS&quot;)).With(p =&gt; p.Replace(&quot;CS&quot;, &quot;&quot;));             var rowSpanPattern = patterns.FirstOrDefault(p =&gt; p.StartsWith(&quot;RS&quot;)).With(p =&gt; p.Replace(&quot;RS&quot;, &quot;&quot;));             int column, row, columnSpan, rowSpan;             if (int.TryParse(columnSpanPattern, out columnSpan)) Grid.SetColumnSpan(element, columnSpan);             if (int.TryParse(rowSpanPattern, out rowSpan)) Grid.SetRowSpan(element, rowSpan);             if (int.TryParse(columnPattern, out column)) Grid.SetColumn(element, column);             if (int.TryParse(rowPattern, out row)) Grid.SetRow(element, row);         }          private static GridLength ToGridLength(this string length)         {             try             {                 length = length.Trim();                 if (length.ToLowerInvariant().Equals(&quot;auto&quot;)) return new GridLength(0, GridUnitType.Auto);                 if (!length.Contains(&quot;*&quot;)) return new GridLength(double.Parse(length), GridUnitType.Pixel);                 length = length.Replace(&quot;*&quot;, &quot;&quot;);                 if (string.IsNullOrEmpty(length)) length = &quot;1&quot;;                 return new GridLength(double.Parse(length), GridUnitType.Star);             }             catch (Exception exception)             {                 Debug.WriteLine(exception.Message);                 return new GridLength();             }         }     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/276077\/\"> https:\/\/habrahabr.ru\/post\/276077\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0443\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430 <i>Grid<\/i>.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/741\/5d8\/8d1\/7415d88d178848f6a1c93df00c75657c.jpg\" alt=\"image\"\/><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-273112","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/273112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=273112"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/273112\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=273112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=273112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=273112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}