Chia sẻ

Bài này chúng ta sẽ thực hiện tải ảnh vào Rectangle trong WPF. Để thực hiện làm như sau:

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WPF" Height="300" Width="380">
    <StackPanel Orientation="Horizontal">
        <Canvas Margin="5">
            <Canvas.Resources>
                <ImageBrush x:Key="IB1" ImageSource="c:image.jpg" 
                            Stretch="UniformToFill" TileMode="FlipXY" 
                            Viewport="0,0,0.2,0.2" />
            </Canvas.Resources>
            <Rectangle Canvas.Top="5" Canvas.Left="5"
                       Height="180" Width="80" 
                       Fill="{StaticResource IB1}" />
        </Canvas>
    </StackPanel>
</Window>

Chúc các bạn thành công.

 

ĐĂNG KÝ MUA HÀNG

    Email (*)

    Điện thoại (*)

    Tên sản phẩm/Dịch vụ:


    Chia sẻ
    Xem thêm  [WPF] Tạo Textbox nhiều dòng trong WPF

    Trả lời

    Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *