title: How to Bind Sum of width of two control to MinWidth of another control
body: <p>I wanna set MinWidth of column of grid, which should be sum of Actual Width of a Label and a Button control inside another grid placed inside the cell of a column. I am using a Converter class for this purpose but figure out the XAML part.
  Converter is here:</p>
  
  <pre><code>class StringSumtoIntConverter : IMultiValueConverter
  {
      public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
      {
          int sum = 0;
          foreach (var item in value)
          {
              sum += System.Convert.ToInt32(item);
          }
  
          return sum;
      }
      //...Other implementations
  }
  </code></pre>
  
  <p>XAML code I have written till now is:</p>
  
  <pre><code>xmlns:helperClasses="clr-namespace:EmbroidaryManagementSystem_V2._0.HelperClasses" &lt;!--Import class--&gt;
  
  &lt;helperClasses:StringSumtoIntConverter x:Key="StringSumtoIntConvert"/&gt;  &lt;!--Inside Window.Resources tag--&gt;
  
  &lt;ColumnDefinition Width="48*"&gt; &lt;!--Inside Grid--&gt;
      &lt;ColumnDefinition.MinWidth&gt;
          &lt;MultiBinding Converter="{StaticResource StringSumtoIntConvert}"&gt;
              &lt;Binding Path=""&gt;&lt;/Binding&gt;
          &lt;/MultiBinding&gt;
      &lt;/ColumnDefinition.MinWidth&gt;
  &lt;/ColumnDefinition&gt;
  </code></pre>
  
  <p>Complete implementation of XAML is here:</p>
  
  <pre><code>&lt;Window x:Class="EmbroidaryManagementSystem_V2._0.View.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:EmbroidaryManagementSystem_V2._0.View"
      xmlns:y="clr-namespace:EmbroidaryManagementSystem_V2._0.ViewModel.CollectionsViewModel"
      xmlns:helperClasses="clr-namespace:EmbroidaryManagementSystem_V2._0.HelperClasses"
      mc:Ignorable="d"
      Title="MainWindow" Height="655.512" Width="1120.159" FontSize="24" WindowStartupLocation="CenterScreen"
      &gt;
  &lt;Window.Resources&gt;
      &lt;helperClasses:StringSumtoIntConverter x:Key="StringSumtoIntConvert"/&gt;
  &lt;/Window.Resources&gt;
  &lt;Window.DataContext&gt;
      &lt;y:ClientCollectionVM/&gt;
  &lt;/Window.DataContext&gt;
  &lt;Grid HorizontalAlignment="Left" Height="622" VerticalAlignment="Top" Width="1110" Background="#FFD6DBE9"&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="89*"/&gt;
          &lt;RowDefinition Height="39*"/&gt;
          &lt;RowDefinition Height="494*"/&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="137*"/&gt;
          &lt;ColumnDefinition Width="48*"&gt;
              &lt;ColumnDefinition.MinWidth&gt;
                  &lt;MultiBinding Converter="{StaticResource StringSumtoIntConvert}"&gt;
                      &lt;Binding Path=""&gt;&lt;/Binding&gt;
                  &lt;/MultiBinding&gt;
              &lt;/ColumnDefinition.MinWidth&gt;
          &lt;/ColumnDefinition&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;GridSplitter x:Name="gridSplitter" Grid.Column="1" HorizontalAlignment="Left" Height="533" Grid.Row="1" 
                    VerticalAlignment="Top" Width="2" Grid.RowSpan="2"/&gt;
      &lt;Grid Grid.Column="1" Height="35" Background="#FF657695" 
            Grid.Row="1" VerticalAlignment="Top"&gt;
          &lt;Label x:Name="lblNotificationsHeader" Content="Notifications" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="14.667" Height="30" Foreground="#FFEBF0EE"/&gt;
          &lt;Button x:Name="btnNotificationsClose" Content="X" 
                  Margin="0,5,8,0" VerticalAlignment="Top" Width="20" FontFamily="Verdana" HorizontalAlignment="Right" Background="Transparent" FontSize="13.333" Foreground="Black"/&gt;
      &lt;/Grid&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>Also there is an error saying: Unable to cast object of type 'EmbroidaryManagementSystem_V2._0.ViewModel.CollectionsViewModel.ClientCollectionVM' to type 'System.IConvertible'.
  At line: </p>
  
  <pre><code>&lt;MultiBinding Converter="{StaticResource StringSumtoIntConvert}"&gt;
                          &lt;Binding Path=""&gt;&lt;/Binding&gt;
                      &lt;/MultiBinding&gt;
  </code></pre>
  
  <p>I don't know why.</p>