I have this WPF slider:
<Slider Height="22" HorizontalAlignment="Left" Width="100" TickPlacement="BottomRight" AutoToolTipPlacement="BottomRight" TickFrequency="1" Minimum="10" Maximum="110" Value="{Binding Path=Zoom, Mode=TwoWay}" Ticks="100"/>
and my c# code behind
public object Zoom
{
get { return _zoom.ToString() }
set
{
try
{
string zoom = value.ToString().Replace(",", ".");
if (zoom.EndsWith(" %"))
{
_zoom= System.Convert.ToInt32(System.Convert.ToInt64(zoom));
}
OnPropertyChanged("CurrentZoom");
}
catch (FormatException ex)
{
//TODO: =)
}
}
}
how is it possible that only integers can be stored in _zoom? I don’t need a decimal number.
for example:
zoom is “13,99999”
_zoom should be 13 (int)
_zoom= System.Convert.ToInt32(System.Convert.ToInt64(zoom));
so i get this error:
Value was either too large or too small for an Int32.
whats wrong?
1 Answer