Since we cant provide an accurate solution without seeing your code.
Here is a check list you can follow to find out the bug:
1.Debug your Converter and check if it is returning desired value for all test cases.
2.Check if all the names are proper and there isn't any typo in ur xaml.
Here is an implementation for binding column span with an vm and updating it with a command bound to the click event.
<Page.Resources>
<local:BoolToColumnSpanConverter x:Key="BoolToColumnSpanConverter" />
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.DataContext>
<local:Items />
</Grid.DataContext>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Rectangle HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Fill="Red"
Grid.ColumnSpan="{Binding span, Converter={StaticResource BoolToColumnSpanConverter}}" />
<Button Click="Button_Click"
Content="change span"
Grid.ColumnSpan="2"
Grid.Column="2"
Margin="5"
Command="{Binding ChangeSpanCommand, Mode=OneWay}" />
</Grid>
the code behind:
The Converter just converts true to 2 and false to 1
The command is bound to a method in the VM called UpdateSpan which just turns the boolean inverse.
When the button is pressed , since it is bound to the command the command is called, since it just returns a new relaycommand with the UpdateSpan as a parameter this method is executed .. which will update the span boolean triggering a change which is notified by the System thru the OnPropertyChanged event and the value converter is executed turning the columnspan to 1 and 2 .
public class BoolToColumnSpanConverter : IValueConverter
{
public object Convert( object value , Type targetType , object parameter , string language )
{
var b = (bool)value;
return b ? 2 : 1;
}
public object ConvertBack( object value , Type targetType , object parameter , string language )
{
throw new NotImplementedException();
}
}
public class Items : INotifyPropertyChanged
{
private bool _span;
public bool span
{
get { return _span; }
set
{
if (value != _span) _span = value;
OnPropertyChanged();
}
}
public ICommand ChangeSpanCommand {
get
{
return new RelayCommand(() => UpdateSpan());
}
}
public Items()
{
span = true;
}
public void UpdateSpan()
{
span = !span;
}
#region Notify Property Changed Members
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged( [CallerMemberName]string propertyName = null )
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this , new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}
public class RelayCommand : ICommand
{
public event EventHandler CanExecuteChanged;
public bool CanExecute( object parameter )
{
return true;
}
public void Execute( object parameter )
{
this._action();
}
private Action _action;
public RelayCommand( Action action )
{
this._action = action;
}
}