Info about Image in C# WPF

first: do u know why I can't get the method FromFile? ex: I can't write Image.FromFile

second: Do u know how I could get the Image Dimensions in c# WPF?

-------------Problems Reply------------

Use the below code to get dimensions of image

BitmapImage image = new BitmapImage(new Uri(@"c:\Images\Image1.JPG"));
double width = image.Width;
double height = image.Height;

  1. Because the FromFile static method is from System.Drawing namespace. In wpf you've to set the image source using the Source property. Take a look at this example in msdn

  2. You can use the Height and Width property for setting the dimensions
Category:wpf Views:0 Time:2010-06-25
Tags: wpf

Related post

  • Numeric Data Entry in WPF 2008-08-08

    How are you handling the entry of numeric values in WPF applications? Without a NumericUpDown control, I've been using a TextBox and handling its PreviewKeyDown event with the code below, but it's pretty ugly. Has anyone found a more graceful way to

  • How do I generate WPF controls through code 2008-08-11

    I was trying to get my head around XAML and thought that I would try writing some code. Trying to add a grid with 6 by 6 column definitions then add a textblock into one of the grid cells. I don't seem to be able to reference the cell that I want. Th

  • What real world WPF applications are out there? 2008-08-11

    I'm currently working with WPF and Ive seen a couple of examples on dnrtv and some other places. I'd like to see more real stuff. Anybody knows of good examples? The list so far: http://en.wikipedia.org/wiki/Windows_Presentation_Foundation#WPF_Applic

  • WPF: How to style or disable the default ContextMenu of a TextBox 2008-08-13

    Apparantly when users right-click in our WPF application, and they use the Windows Classic theme, the default ContextMenu of the TextBox (which contains Copy, Cut and Paste) has a black background. I know this works well: <Page xmlns="http://schem

  • WPF - Sorting a composite collection 2008-08-14

    So WPF doesn't support standard sorting or filtering behavior for views of CompositeCollections, so what would be a best practice for solving tihs problem. There are two or more object collections of different types. You want to combine them into a s

  • How to host a WPF form in a MFC application 2008-08-14

    I'm looking for any resources on hosting a WPF form within an existing MFC application. Can anyone point me in the right direction on how to do this? --------------Solutions------------- From what I understand (haven't tried myself), it's almost as s

  • How to get list of installed BitmapEncoders/Decoders (the WPF world)? 2008-08-18

    In WindowsForms world you can get a list of available image encoders/decoders with System.Drawing.ImageCodecInfo.GetImageDecoders() / GetImageEncoders() My question is, is there a way to do something analogous for the WPF world that would allow me to

  • Enabling a button in WPF depending on ListBox.SelectedIndex 2008-08-20

    I have a rather classic UI situation - two ListBoxes named SelectedItems and AvailableItems - the idea being that the items you have already selected live in SelectedItems, while the items that are available for adding to SelectedItems (i.e. every it

  • WPF Anti aliasing workaround 2008-08-22

    Anti aliasing cannot be turned off in WPF. But I want to remove the blurred look of WPF fonts when they are small. One possibility would be to use a .net 2.0 component. This looks like it would lose the transparency capability and Blend support. Neve

  • So what am I missing with this here WPF? 2008-08-26

    Background: I have a little video playing app with a UI inspired by the venerable Sasami2k, just updated to use VMR9 (i.e. Direct3D9 with DirectShow) and be less unstable. Currently, it's a C++ app using raw Win32, through necessity: none of the vari

  • How do I set ItemTemplate dynamically in WPF? 2008-08-27

    Using WPF, I have a TreeView control that I want to set its ItemTemplate dynamically through procedural code. How do I do this? I assume I need to find the resource somewhere. myTreeViewControl.ItemTemplate = ?? --------------Solutions------------- I

  • How can you clone a WPF object? 2008-08-28

    Anybody have a good example how to deep clone a WPF object, preserving databindings? The marked answer is the first part. The second part is that you have to create an ExpressionConverter and inject it into the serialization process. Details for this

  • How to get controls in WPF to fill available space? 2008-08-30

    Some WPF controls (like the Button) seem to happily consume all the availible space in its' container if you don't specify the height it is to have. And some, like the ones I need to use right now, the (multiline) TextBox and the ListBox seem more wo

  • Why do .Net WPF DependencyProperties have to be static members of the class 2008-08-31

    Learning WPF nowadays. Found something new today with .Net dependency properties. What they bring to the table is Support for Callbacks (Validation, Change, etc) Property inheritance Attached properties among others. But my question here is why do th

  • How popular is WPF as a technology? 2008-09-01

    I had a discussion with some colleagues mentioning that there are not too many projects that we do which make use of WPF for creating UI for a windows application (we almost always use Windows Forms instead). Are your experiences the same - i.e. ther

  • What tools do you use for WPF development? 2008-09-02

    What tools beside Visual Studio's Cider do you use? Have you succeed in using something from Microsoft Expression product family? EDIT: Here are revealed tools: Snoop Mole debugger visualizer Perforator suggested by Matt Hamilton The Expression Blend

  • How do I create a base page in WPF? 2008-09-02

    I have decided that all my WPF pages need to register a routed event. Rather than include public static readonly RoutedEvent MyEvent= EventManager.RegisterRoutedEvent("MyEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(BasePage)); o

  • Find item in WPF ComboBox 2008-09-03

    I know in ASP.NET I can get an item from a DropDownList by using DropDownList1.Items.FindByText Is there a similar method I can use in WPF for a ComboBox? Here's the scenario. I have a table called RestrictionFormat that contains a column called Rest

  • How well does WPF blend with XNA in real life? 2008-09-04

    I understand that there are several ways to blend XNA and WPF within the same application. I find it enticing to use WPF for all GUI and HUD stuff in my XNA games. Does anyone have any practical experience on how well this approach works in real life

  • Is there a good WPF diagrammer / toolkit / provider? 2008-09-04

    Basically we need a custom diagram component in our new WPF based application. Needs to show text/lines, linked 2D Nodes and custom images apart from the other diagramming features like Undo/Redo, Align, Group, etc.. ala Visio. The initial team did a

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.230 (s). 11 q(s)