Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
is it Possible to Add an image to the Toolkit custom messageBox as Content?
because i tried and it didnt work, the Messagebox is Blank.
Here is what i have tried:
C#
Image image = new Image();
            image.Height = 250;
            image.Width = 300;
            image.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            image.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            image.Margin = new Thickness(0, 12, 0, 12);
            image.Source = new BitmapImage() { UriSource = new Uri(@"/Assets/AppBar/AddToCart.png") };
            CustomMessageBox dialogBox = new CustomMessageBox()
            {
                Title = "Add to cart?",
                FontSize = 38,
                FontWeight = FontWeights.Thin,
                Margin = new Thickness(0,0,0,0),
                Content = image,
                LeftButtonContent = "Yes",
                RightButtonContent = "Cancel",
            }; 
Posted
Updated 28-Sep-14 3:21am
v5
Comments
[no name] 27-Sep-14 8:00am    
What exactly does "didnt work" mean?
job mwa 27-Sep-14 8:09am    
the MessageBox is Blank.
[no name] 27-Sep-14 8:14am    
So debug your code and find out why the image is not loading.
job mwa 27-Sep-14 11:44am    
i have tried everything what im i doing wrong??


There's now way for us to tell you what's wrong.

YOU have to step through the code and find out why the asset isn't being loaded by the creation of the BitmapImage() object. It would probably help if you broke that line out into it's own variable so you can set a breakpoint on it and examine the values and any error messages it throws.

Seriously, the part about "I have tried everything what am I doing wrong?" is bullshit because you have NOT tried everything and what you're doing wrong has nothing to do with the code but everything to do with your debugging skills.
 
Share this answer
 
Comments
job mwa 29-Sep-14 10:05am    
@Dave where have you read me saying "i have tried everything and it didn't work" ?obviously i haven't tried everything.
Any Way i also set the image in XAML and it didn't work either my Question was if someone has been successful in setting up an image in a Custom Message Box and according to your comment its possible so ill try a different way of setting the Image source.
Dave Kreskowiak 29-Sep-14 11:48am    
I quote: "I have tried everything what im I doing wrong?"

The first thing I would look at would be the URI source that you specified. This is where debugging skills come into play.
i used:
C#
image.Source = new BitmapImage(new Uri(@"Assets/AppBar/AddToCart.png",UriKind.RelativeOrAbsolute))

Thanks for the Suggestions to all of you and taking your time to comment God Bless you..

Happy Coding.. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900