Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 布局转换中的ScaleTransform不起作用,但可与RenderTransform一起使用_C#_Wpf_Xaml_Mvvm_Wpf 4.0 - Fatal编程技术网

C# 布局转换中的ScaleTransform不起作用,但可与RenderTransform一起使用

C# 布局转换中的ScaleTransform不起作用,但可与RenderTransform一起使用,c#,wpf,xaml,mvvm,wpf-4.0,C#,Wpf,Xaml,Mvvm,Wpf 4.0,我试图在我的应用程序中做两件事 1.变焦图像 能够处理渲染转换。但需要在LayoutTransform中实现,以启用Scrollviewer xaml 工作 <Image.RenderTransform> <ScaleTransform ScaleX="{Binding ScaleX}" ScaleY="{Binding ScaleY}" /> </Image.RenderTransform> 不能同时使用ScrollViewer实现Scal

我试图在我的应用程序中做两件事

1.变焦图像 能够处理
渲染转换
。但需要在
LayoutTransform
中实现,以启用
Scrollviewer

xaml 工作

 <Image.RenderTransform>
      <ScaleTransform ScaleX="{Binding ScaleX}" ScaleY="{Binding ScaleY}" />
 </Image.RenderTransform>
不能同时使用
ScrollViewer实现
ScaleTransform
RotateTransform

我试过使用
Canvas

xaml 任何人都可以帮我提建议

“GazTheDestroyer”为我提出的有效解决方案

XAML

尝试将
Stretch=“None”
添加到您的
图像
标签中,否则,请提供明确的高度和宽度


在某些面板中,WPF将自动将图像拉伸到面板中的可用空间,这将使缩放变换在布局过程中变得多余。

长问题,小答案。成功了。我会把它寄出去。
<Image.LayoutTransform>
     <ScaleTransform ScaleX="{Binding ScaleX}" ScaleY="{Binding ScaleY}" />
</Image.LayoutTransform>
<Image.LayoutTransform>
    <TransformGroup> 
       <ScaleTransform ScaleX="{Binding ScaleX}" ScaleY="{Binding ScaleY}" />
       <RotateTransform Angle="{Binding RotateAngle}"/>
    </TransformGroup>
</Image.LayoutTransform>
<Canvas.LayoutTransform>
   <TransformGroup> 
      <ScaleTransform ScaleX="{Binding ScaleX}" ScaleY="{Binding ScaleY}" />
      <RotateTransform Angle="{Binding RotateAngle}"/>
   </TransformGroup>
</Canvas.LayoutTransform>
<ScrollViewer>
    <Viewbox  RenderTransformOrigin="0.5,0.5" Height="Auto" Width="Auto" ScrollViewer.CanContentScroll="True">
         <Viewbox.LayoutTransform>
                <TransformGroup> 
                    <ScaleTransform ScaleX="{Binding ScaleX}" ScaleY="{Binding ScaleY}" />
                    <RotateTransform Angle="{Binding RotateAngle}"/>
                </TransformGroup>
            </Viewbox.LayoutTransform>
        <Image RenderTransformOrigin="0.5,0.5" >               
            <Image.Source>                    
                <BitmapImage UriSource="{Binding ImagePath}" ScrollViewer.CanContentScroll="True"></BitmapImage>
            </Image.Source>
        </Image>
    </Viewbox>
 </ScrollViewer>
<Image RenderTransformOrigin="0.5,0.5" Stretch="None" >
            <Image.LayoutTransform>
                <TransformGroup>
                  <ScaleTransform ScaleX="{Binding ScaleX}" ScaleY="{Binding ScaleY}" />
                  <RotateTransform Angle="{Binding RotateAngle}"/>
               </TransformGroup>
           </Image.LayoutTransform>
         <Image.Source>                    
           <BitmapImage UriSource="{Binding ImagePath}" ScrollViewer.CanContentScroll="True"></BitmapImage>
         </Image.Source>
 </Image>