How to set WPFExtensions.ZoomControl Default Zoom
Does any开发者_如何学Goone know how to set the default zoom level to 1:1 in the ZoomControl included in wpfextensions? When the project first starts the default behavior is to zoom to fill.
I have tried both
<zoom:ZoomControl Mode="Original">
and
<zoom:ZoomControl Zoom="1">
both didn't work...
Looks like you have to set the Mode property to Original
, or you can explicitly call ZoomToOriginal
in a Loaded event handler for the ZoomControl.
It also appears that the EqualityToBooleanConverter will throw an exception, when it shouldn't. The code looks like:
public class EqualityToBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return object.Equals(value, parameter);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((bool)value)
return parameter;
//it's false, so don't bind it back
throw new Exception("EqualityToBooleanConverter: It's false, I won't bind back.");
}
}
You would need to remove that exception and return Binding.DoNothing, instead.
That converter is used in the control template of ZoomControl, like so:
<RadioButton Content="1:1"
GroupName="rbgZoomMode"
IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Mode,Converter={StaticResource equalityConverter},ConverterParameter={x:Static Controls:ZoomControlModes.Original}}" />
<RadioButton Content="Fill"
GroupName="rbgZoomMode"
IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Mode,Converter={StaticResource equalityConverter},ConverterParameter={x:Static Controls:ZoomControlModes.Fill}}" />
So effectively, it's trying to only bind back to the source if value is true. But it throws an exception, as you've seen.
精彩评论