如何在xaml中执行Items.Count -1?

时间:2011-11-14 11:43:47

标签: silverlight silverlight-4.0

<Slider Maximum="{Binding ElementName=flowControl, Path=Items.Count}" />

我需要返回一个Items.Count - 1作为滑块的最大值。我如何在xaml中定义它?

非常感谢,

2 个答案:

答案 0 :(得分:1)

我认为在这种情况下你必须使用Value Converter

e.g。

public class MaxCountConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        return (int)value - 1;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

你可能需要做错误处理和事情,这只是给你一个起点。

答案 1 :(得分:0)

使用转换为1的转换器。