开发者

Help with Image and ScrollViewer - WPF

开发者 https://www.devze.com 2023-01-16 11:56 出处:网络
I have a Wpf windows like: ScrollViewer > Grid > Image image is <Image Margin=\"20,15,10,20\" Grid.Row=\"1\" Stretch=\"Uniform\" Source=\"Images/logo.png\" />

I have a Wpf windows like: ScrollViewer > Grid > Image

image is <Image Margin="20,15,10,20" Grid.Row="1" Stretch="Uniform" Source="Images/logo.png" />

the image I want to take only the visible size of the cell in with it is inside, it works exactly as I want if I remove the ScrollViewer, but if I add it, the image takes the size it wants and the scrollbar is added...

My intention is to use scrollbars if controls like buttons etc needs it, not the bg image I'm using...

how can exclude it from layout measuring or something that will just ignore the size the image wants and use the size available in the grid's cel?

I don't want to set a fixed size for the image, I want it to take the visible size onl开发者_如何学Pythony... to workaround this I just set a fixed size, but it just doesn't look good..

thanks


fixed it... with:

        <Rectangle Margin="20,15,10,20" Grid.Row="1" RadiusX="10" RadiusY="10">
            <Rectangle.Fill>
                <ImageBrush Stretch="Uniform">
                    <ImageBrush.ImageSource>
                        <BitmapImage UriSource="Images/logo.png" />
                    </ImageBrush.ImageSource>
                </ImageBrush>
            </Rectangle.Fill>
        </Rectangle>
0

精彩评论

暂无评论...
验证码 换一张
取 消