Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6788965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:32:51+00:00 2026-05-26T17:32:51+00:00

When I set my image margin in run-time it acts strange, different then when

  • 0

When I set my image margin in run-time it acts strange, different then when I set it via xaml code.

I want the margin value to be (40, 16, 0, 0).

When I add it in run-time, my code is this:

        System.Windows.Controls.Image proba = new System.Windows.Controls.Image();
        ImageSource imageSource = GetSlidePart(PresentationDocument.Open(path, false), 0, "rId2");
        proba.Source = imageSource;
        proba.Width = 2245721 / 9525;
        proba.Height = 2286004 / 9525;
        proba.Margin = new Thickness(40, 16, 0, 0);
        gridName.Children.Add(proba);

But, when I add image in xaml, the code in cs is this:

        image1.Source = GetSlidePart(PresentationDocument.Open(path, false), 0, "rId2");

and the code in xaml is this:

<Window x:Class="GetInfoFromPptxFile.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="720" Width="960">

<Grid Name="gridName">
    <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="416,20,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
    <Image Height="150" HorizontalAlignment="Left" Margin="40,16,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="200" />
</Grid>
</Window>

When I run my program, image1 is exactly where I want it to be, and the image named proba is not. Why is this when I give them the same margin values?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:32:52+00:00Added an answer on May 26, 2026 at 5:32 pm

    That’s because you’re not setting the horizontal and vertical alignments in C#.

    Try adding:

    proba.VerticalAlignment = VerticalAlignment.Top;
    proba.HorizontalAlignment = HorizontalAlignment.Left;
    

    and it’ll look the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is possible to set an image as an iPhone application unique icon in code
I want to set a background image for a div, in a way that
I want to set the thumb image of a slider for a normal state,
I want to set an active class for a CSS image menu. I tried
I want to watermark an image and save it. here is the code i
I have an image with a square... In layout I want to set text
I have one image on top of another.In code I am trying to set
i am using android:layout_marginTop=100dip in my imageview,i want to set margin top to each
I have created a Python file to generate a Mandelbrot set image. The original
How can i set an image to a circular slider, which is an object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.