相关疑难解决方法(0)

如何进行图像拉伸以填充此WPF/XAML应用程序?

当我的程序显示的图像小于XAML中定义的图像GUI对象时,它不会像我希望的那样被拉伸.例如,256x256图像仅占据我的512x512图像GUI对象的左上象限.我很困惑因为我在XAML代码中设置了Stretch ="Fill".我还需要做什么?任何有关代码的帮助(见下文)将不胜感激.

定义GUI的XAML代码

  <Window x:Class="MyProgram.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MyProgarm" Height="900" Width="890" Name="mainWindow" Icon="Icon.ico" MouseDown="mouseDown">
        <Grid Name="mainGrid" Background="#FFEBE7F0" Width="800.10">
          <Border Margin="139,32,0,0" Name="border1" Height="512" VerticalAlignment="Top" HorizontalAlignment="Left" Width="512" Background="#F0D4D0D0" />
          <Border Margin="138,602,0,0" Name="border2" Height="256" VerticalAlignment="Top" HorizontalAlignment="Left" Width="256" Background="#F0D4D0D0" />
          <Border Margin="400,602,0,0" Name="border3" Height="256" VerticalAlignment="Top" HorizontalAlignment="Left" Width="256" Background="#F0D4D0D0" />
          <Image Margin="135,32,0,0" Name="imagePanel1" Stretch="Fill" HorizontalAlignment="Left" Width="512" MouseMove="imagePanelAxl_MouseMove" Height="512" VerticalAlignment="Top" Canvas.Left="-135" Canvas.Top="-32">
          </Image>
Run Code Online (Sandbox Code Playgroud)

我用来绘制图像的代码:

byte[] myColorImage=// 256x256 RGB image loaded from disk

int W=256;
int H=256;  // dimensions of myColorImage
// Use multiple cores
image.Dispatcher.BeginInvoke(
System.Windows.Threading.DispatcherPriority.Normal,
new …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml image stretch

5
推荐指数
2
解决办法
3万
查看次数

图像填充WPF中按钮的空间

我有Button我的WPF应用程序,我想一个Image填补Button彻底.目前我有以下代码,它没有填写Button.

<Image x:Key="MyResource" Source="Images/up-arrow-icon.jpg" Margin="0" />

<telerik:RadButton  Height="25" Width="40" HorizontalAlignment="Left" Margin="417,10,0,0" 
                    Name="radButton1" VerticalAlignment="Top" Click="UpButtonClick">
    <telerik:RadButton.Content>
        <StaticResource ResourceKey="MyResource"/>
    </telerik:RadButton.Content>
</telerik:RadButton>
Run Code Online (Sandbox Code Playgroud)

我是否需要调整Image外部WPF的大小然后使用它?

wpf xaml image telerik button

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

image ×2

wpf ×2

xaml ×2

button ×1

c# ×1

stretch ×1

telerik ×1