title: How to get listview column lines with dynamically changing column width in MVVM pattern
body: <p>I have a list view in wpf, with 3 comboboxes and 2 checkbox as columns. I play with checkbox visibility based on some search criteria. I could achieve horizontal line between rows, however i could not achieve vertical line to separate columns. I change the visibility of checkbox &amp; column width from my model.I need to follow MVVM pattern. 
  Help much appreciated. 
  Thanks in advance.</p>
  
  <p>Below is my xaml code</p>
  
  <pre><code>&lt;ListView  Grid.ColumnSpan="3" Grid.Column="1" Grid.Row="2" 
                             ItemsSource="{Binding NewTransactionSetlist,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" 
                            SelectedItem="{Binding SelectedNewItem,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                             SelectedIndex="{Binding SelectedNewIndex, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                             VerticalAlignment="Top" Height="320"  SelectionMode="Single" 
                            HorizontalAlignment="Center" Width="1240"&gt;
                      &lt;ListView.ItemContainerStyle&gt;
                          &lt;Style TargetType="{x:Type ListViewItem}"&gt;
                              &lt;Setter Property="Padding" Value="0,2"/&gt;
                              &lt;Setter Property="BorderBrush" Value="LightGray"/&gt;
                              &lt;Setter Property="BorderThickness" Value="0,0,0,1"/&gt;
                              &lt;Setter Property="HorizontalContentAlignment" Value="Stretch"/&gt;
                              &lt;!--&lt;EventSetter Event="PreviewGotKeyboardFocus" Handler="SelectCurrentItem" &gt;&lt;/EventSetter&gt;
                              &lt;Style.Triggers&gt;
                                      &lt;Trigger Property="IsKeyboardFocusWithin" Value="true"&gt;
                                          &lt;Setter Property="IsSelected" Value="true" /&gt;
                                      &lt;/Trigger&gt;
                                  &lt;/Style.Triggers&gt;--&gt;
                              &lt;!--&lt;Style.Triggers&gt;
                                  &lt;DataTrigger Binding="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Value="True"&gt;
                                      &lt;Setter Property="IsSelected" Value="True"  /&gt;
                                  &lt;/DataTrigger&gt;
                              &lt;/Style.Triggers&gt;--&gt;
  
                          &lt;/Style&gt;
                      &lt;/ListView.ItemContainerStyle&gt;
                      &lt;!--&lt;i:Interaction.Triggers&gt;
                          &lt;i:EventTrigger EventName="PreviewGotKeyboardFocus"&gt;
                              &lt;i:InvokeCommandAction Command="{Binding PreviewGotKeyboardFocusCommand}" 
                                                    /&gt;
                          &lt;/i:EventTrigger&gt;
                      &lt;/i:Interaction.Triggers&gt;--&gt;
                      &lt;!--&lt;Style TargetType="{x:Type ListViewItem}"&gt;
                           &lt;Style.Triggers&gt;
                              &lt;DataTrigger Binding="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Value="True"&gt;
                                  &lt;Setter Property="IsSelected" Value="True"  /&gt;
                              &lt;/DataTrigger&gt;
                          &lt;/Style.Triggers&gt;
                      &lt;/Style&gt;--&gt;
                      &lt;ListView.InputBindings&gt;
                          &lt;KeyBinding 
                           Key="Delete" 
                           Command="{Binding NewTransactionDataGridRowDeleteCommand}"/&gt;
                      &lt;/ListView.InputBindings&gt;
                      &lt;ListView.View&gt;
                          &lt;GridView ColumnHeaderContainerStyle="{StaticResource GridViewHeaderStyle}"&gt;
                              &lt;GridViewColumn Header="Transaction" Width="{Binding NewTransactionHeaderLength,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"   &gt;
                                  &lt;GridViewColumn.CellTemplate&gt;
                                      &lt;DataTemplate&gt;
                                              &lt;ComboBox x:Name="ComboBoxParamList" HorizontalAlignment="Left" Width="{Binding TransactionHeaderLength,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                    IsEditable="False" Style="{DynamicResource DatagridComboboxFontstyle}" 
                                                Text="{Binding ParamGroup, Mode=TwoWay, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" 
                                                SelectedValue ="{Binding ParamGroup, Mode=TwoWay, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" 
                                                ItemsSource="{Binding ParamGroupList}" &gt;
                                              &lt;i:Interaction.Triggers&gt;
                                                  &lt;i:EventTrigger EventName="SelectionChanged"&gt;
                                                      &lt;i:InvokeCommandAction Command="{Binding DataContext.ParameterNewSelectionChangedCommand, 
                                                      RelativeSource={RelativeSource AncestorType=ListView}}"/&gt;
                                                  &lt;/i:EventTrigger&gt;
                                              &lt;/i:Interaction.Triggers&gt;
                                          &lt;/ComboBox&gt;
                                      &lt;/DataTemplate&gt;
                                  &lt;/GridViewColumn.CellTemplate&gt;
                              &lt;/GridViewColumn&gt;
                              &lt;GridViewColumn Header="System" Width="{Binding NewSystemHeaderLength,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"&gt;
                                  &lt;GridViewColumn.CellTemplate&gt;
                                      &lt;DataTemplate&gt;
                                              &lt;ComboBox x:Name="ComboBoxSystemList"  HorizontalAlignment="Left" Width="{Binding SystemHeaderLength,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                    IsEditable="False" Style="{DynamicResource DatagridComboboxFontstyle}" 
                                                Text="{Binding SystemName, Mode=TwoWay, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" 
                                                SelectedValue ="{Binding SystemName, Mode=TwoWay, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" 
                                                ItemsSource="{Binding SystemNameList}"   /&gt;
                                      &lt;/DataTemplate&gt;
                                  &lt;/GridViewColumn.CellTemplate&gt;
                              &lt;/GridViewColumn&gt;
                              &lt;GridViewColumn Header="HandAdd" Width="{Binding NewHandAddHeaderLength,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" &gt;
                                  &lt;GridViewColumn.CellTemplate&gt;
                                      &lt;DataTemplate&gt;
                                              &lt;CheckBox Name="CheckBoxNewHandAdd" Width="{Binding HandAddHeaderLength,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                    Visibility="{Binding HandAddVisibility,Converter={StaticResource BoolToVisConverter}}"  
                                                    IsChecked="{Binding HandAdd, Mode=TwoWay, NotifyOnSourceUpdated=True, 
                                          UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" Margin="90,0,0,0" &gt;&lt;/CheckBox&gt;
                                      &lt;/DataTemplate&gt;                                        
                                  &lt;/GridViewColumn.CellTemplate&gt;
                              &lt;/GridViewColumn&gt;
                              &lt;GridViewColumn Header="Downstream" Width="{Binding NewDownstreamHeaderLength,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"&gt;
                                  &lt;GridViewColumn.CellTemplate&gt;
                                      &lt;DataTemplate&gt;
                                              &lt;CheckBox Width="{Binding DownstreamHeaderLength,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  
                                                    Visibility="{Binding DownstreamVisibility,Converter={StaticResource BoolToVisConverter}}" 
                                                    IsChecked="{Binding Downstream, Mode=TwoWay, NotifyOnSourceUpdated=True, 
                                          UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center"  Margin="90,0,0,0"&gt;&lt;/CheckBox&gt;
                                      &lt;/DataTemplate&gt;
                                  &lt;/GridViewColumn.CellTemplate&gt;
                              &lt;/GridViewColumn&gt;
                              &lt;GridViewColumn Header="Node" Width="{Binding NewNodeHeaderLength,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"&gt;
                                  &lt;GridViewColumn.CellTemplate&gt;
                                      &lt;DataTemplate&gt;
                                              &lt;ComboBox x:Name="ComboBoxNodeList" Width="{Binding NodeHeaderLength,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                    Text="{Binding Node, Mode=TwoWay, NotifyOnSourceUpdated=True, 
                                          UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" 
                                                    SelectedValue ="{Binding Node, Mode=TwoWay, NotifyOnSourceUpdated=True, 
                                          UpdateSourceTrigger=PropertyChanged}"  IsEditable="False" Style="{DynamicResource DatagridComboboxFontstyle}" 
                                                ItemsSource="{Binding NodeList}" /&gt;
                                      &lt;/DataTemplate&gt;
                                  &lt;/GridViewColumn.CellTemplate&gt;
                              &lt;/GridViewColumn&gt;
                          &lt;/GridView&gt;
                      &lt;/ListView.View&gt;
                  &lt;/ListView&gt;
  </code></pre>