Udostępnij za pośrednictwem


DpiPrescaleThemedImageConverter Class

Definition

Caution

Use the Visual Studio image service and/or Microsoft.VisualStudio.Imaging.CrispImage instead.

Converts an ImageSource into an Image element. If the input image is a BitmapSource, the transformed BitmapSource has its halo color mapped to the given background color and is conditionally rendered as disabled. The resultant image is then pre-scaled on High DPI to the largest zoom multiple of 100% smaller than the DPI zoom. This converter chains the behavior of ThemedImageConverter and DpiPrescaleImageSourceConverter.

public ref class DpiPrescaleThemedImageConverter : Microsoft::VisualStudio::Imaging::Dpi::DpiPrescaleThemedImageConverter
[Windows::Foundation::Metadata::WebHostHidden]
class DpiPrescaleThemedImageConverter : Microsoft::VisualStudio::Imaging::Dpi::DpiPrescaleThemedImageConverter
public class DpiPrescaleThemedImageConverter : Microsoft.VisualStudio.Imaging.Dpi.DpiPrescaleThemedImageConverter
[System.Obsolete("Use the Visual Studio image service and/or Microsoft.VisualStudio.Imaging.CrispImage instead.")]
public class DpiPrescaleThemedImageConverter : Microsoft.VisualStudio.Imaging.Dpi.DpiPrescaleThemedImageConverter
type DpiPrescaleThemedImageConverter = class
    inherit DpiPrescaleThemedImageConverter
[<System.Obsolete("Use the Visual Studio image service and/or Microsoft.VisualStudio.Imaging.CrispImage instead.")>]
type DpiPrescaleThemedImageConverter = class
    inherit DpiPrescaleThemedImageConverter
Public Class DpiPrescaleThemedImageConverter
Inherits DpiPrescaleThemedImageConverter
Inheritance
Attributes

Remarks

/// A common usage pattern can look like this:/// /// Where the image dimensions aren't known at compile time, instead of specifying exact Width/Height properties, /// a layout transform can be specified on the FrameworkElement like this:/// /// Note that when using image pre-scaling, either the original image size has to be specified, /// or a reverse layout transform has to be applied to the result, to maintain the desired original image size

<imaging:DpiPrescaleThemedImageConverter x:Key="DpiPrescaleThemedImageConverter" />  
....  
<ControlTemplate x:Key="MyMenuItemTemplate" TargetType="{x:Type MenuItem}">  
    <ContentPresenter x:Name="Icon" Width="16" Height="16" ContentSource="Icon" />  
...  
</ControlTemplate>     
<Style x:Key="MyMenuItemStyleKey" TargetType="{x:Type MenuItem}">  
///        <Setter Property="Template" Value="{StaticResource MyMenuItemTemplate}" />  
    <Setter Property="Icon">  
        <Setter.Value>  
            <MultiBinding Converter="{StaticResource DpiPrescaleThemedImageConverter}">  
                <Binding Path="Image" />  
                <Binding Path="(imaging:ImageThemingUtilities.ImageBackgroundColor)" RelativeSource="{RelativeSource Self}" />  
                <Binding Source="{x:Static utilities:Boxes.BooleanTrue}" />  
            </MultiBinding>  
        </Setter.Value>  
    </Setter>  
</Style>  

Where the image dimensions aren't known at compile time, instead of specifying exact Width/Height properties, a layout transform can be specified on the FrameworkElement like this:

<ContentPresenter.LayoutTransform>  
    <ScaleTransform ScaleX="{x:Static util:DpiHelper.Default.PreScaledImageLayoutTransformScaleX}" ScaleY="{x:Static util:DpiHelper.Default.PreScaledImageLayoutTransformScaleY}" />  
</ContentPresenter.LayoutTransform>  

Note that when using image pre-scaling, either the original image size has to be specified, or a reverse layout transform has to be applied to the result, to maintain the desired original image size.

Constructors

DpiPrescaleThemedImageConverter()

Initializes a new instance of DpiPrescaleThemedImageConverter.

Properties

DpiHelper

Gets an instance of the DpiHelper.

Methods

CheckValue<T>(Object[], Int32, String)

Validates that values[index] is of type T

(Inherited from MultiValueConverterBase<TTarget>)
Convert(ImageSource, Color, Boolean, Boolean, Object, CultureInfo) (Inherited from DpiPrescaleThemedImageConverter)
Convert(ImageSource, Color, Boolean, Object, CultureInfo) (Inherited from DpiPrescaleThemedImageConverter)
Convert(Object[], Type, Object, CultureInfo)

Microsoft internal use only.

(Inherited from MultiValueConverter<T1,T2,T3,TTarget>)
Convert(T1, T2, T3, Object, CultureInfo)

Microsoft internal use only.

(Inherited from MultiValueConverter<T1,T2,T3,TTarget>)
ConvertBack(Object, Type[], Object, CultureInfo)

Microsoft internal use only.

(Inherited from MultiValueConverter<T1,T2,T3,TTarget>)
ConvertBack(TTarget, T1, T2, T3, Object, CultureInfo)

Microsoft internal use only.

(Inherited from MultiValueConverter<T1,T2,T3,TTarget>)
ConvertBackCore(Object, Type[], Object, CultureInfo) (Inherited from MultiValueConverter<T1,T2,T3,TTarget>)
ConvertCore(Object[], Type, Object, CultureInfo) (Inherited from MultiValueConverter<T1,T2,T3,TTarget>)
MakeConverterFunctionNotDefinedException(String)

An exception thrown when the converter function isn’t defined.

(Inherited from MultiValueConverterBase<TTarget>)
ValidateConvertBackParameters(Object, Type[])

Validates the parameters passed to IMultiValueConverter.ConvertBack

(Inherited from MultiValueConverterBase<TTarget>)
ValidateConvertParameters(Object[], Type)

Validates the parameters passed to IMultiValueConverter.Convert

(Inherited from MultiValueConverterBase<TTarget>)

Applies to