Оки, поведение, что мне нужно, можно достичь с помощью этого кода:
<ColumnDefinition Width="{Binding ElementName=ChatWindow, Path=Width, Mode=OneWay,
UpdateSourceTrigger=PropertyChanged,
Converter={StaticResource columnsWidthConverter},
ConverterParameter=Col0}"/>
<ColumnDefinition Width="{Binding ElementName=ChatWindow, Path=Width, Mode=OneWay,
UpdateSourceTrigger=PropertyChanged,
Converter={StaticResource columnsWidthConverter},
ConverterParameter=Col1}"/>
<ColumnDefinition Width="{Binding ElementName=ChatWindow, Path=Width, Mode=OneWay,
UpdateSourceTrigger=PropertyChanged,
Converter={StaticResource columnsWidthConverter},
ConverterParameter=Col2}"/>
<ColumnDefinition Width="{Binding ElementName=ChatWindow, Path=Width, Mode=OneWay,
UpdateSourceTrigger=PropertyChanged,
Converter={StaticResource columnsWidthConverter},
ConverterParameter=Col3}"/>
<ColumnDefinition Width="{Binding ElementName=ChatWindow, Path=Width, Mode=OneWay,
UpdateSourceTrigger=PropertyChanged,
Converter={StaticResource columnsWidthConverter},
ConverterParameter=Col4}"/>
Преобразователь по ширине столбцов:
public class ColumnsWidthConverter : IValueConverter
{
Dictionary<string, int> _columnToMinimumRequiredWidthMapping = new Dictionary<string, int>()
{
{ "col0", 0 },
{ "col1", 270 },
{ "col2", 520 },
{ "col3", 770 },
{ "col4", 1020 }
};
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string colName = parameter.ToString();
int windowWidth = System.Convert.ToInt32(value.ToString());
const int colWidth = 180;
if (_columnToMinimumRequiredWidthMapping.ContainsKey(colName))
{
return windowWidth >= _columnToMinimumRequiredWidthMapping[colName] ? colWidth : 0;
}
return colWidth;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}