|
You can find the StartupPath if you follow the directions in my post here[^]. You could then do something like the following:
private void AssignImage(string fileName)
{
string path = Path.Combine(Utility.StartupPath, "Icons");
string file = Path.Combine(path, fileName);
myImage.BeginInit();
myImage.Source = new BitmapImage(file);
myImage.EndInit();
}
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks, this might work. But I'd have to go and do this for each and every one of my icons that I use, which is quite a lot. Isn't there an easy way to just specify the icon path in the XAML? I tried using Pack URI's but I had no luck
|
|
|
|
|
There's no reason you couldn't convert this logic into an attached property and attach it that way.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
The main reason I want to do this is because I want to move my Icons folder to the Bin folder. All icons I use are stored in this folder. I want to move it to the Bin folder because this makes things easier when creating a setup project, and I don't know of any other way. So how would one normally go about creating a Setup project for an application that uses icons? Almost all apps use them, and don't tell me all developers have to follow this approach that you're telling me to take now?
|
|
|
|
|
Why aren't you applying them as resources then? These are embedded in the exe, so don't need to be added to your setup project. I don't see what benefit you've got keeping them external to the application.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Well that's what I'm doing, but for some or other reason my app crashes when I install and run it. It runs fine when I take out all the icons, that's why I thought it might be the icons' path. Can it be something else then?
|
|
|
|
|
Without seeing what you're doing with the images, it's hard to say. I use inline images regularly with no problems - what format are they, and why not try creating an app with one of your images in? Install the app, and see if it crashes - it may be that there is a problem with just one of these images, and I'd isolate the problem first.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I specified my resources wrong, that's why it wasn't embedded in the exe. I typed in the path manually e.g. Source="Icons/icon.ico" instead of choosing them from the list in the properties pane. When choosing an icon/image from this list the Source changes to /SolutionName;component/Icons/icon.ico , and this works perfectly
|
|
|
|
|
Hi... I am working on project fee and student management in college and require documentation and source code in WPF.Pls reply soon .
|
|
|
|
|
tina sharma wrote: I am working on project fee and student management in college and require documentation and source code in WPF.
Don't hold your breath
|
|
|
|
|
tina sharma wrote: I am working
tina sharma wrote: and require documentation and source code
'I am working' and 'give me source code' are mutually exclusive. Did you mean to say 'I am lazy and require source code ' ?
Tell your teacher you're not capable of completing this course so you stop wasting his time and everyone elses.
They teach WPF in colleges now ? That's bizarre.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
You encapsulated my thoughts so succinctly
Christian Graus wrote: They teach WPF in colleges now ?
I wonder sometimes whether they actually teach anything ...
|
|
|
|
|
sharma g kahna se ho aap aur wat ur doing????????//
|
|
|
|
|
I think I know what the answer is going to be here, but I'm desperate...
I need to use an object wrapper (quite a complex one for a complex reason) in my Silverlight 3 (not using RIA services) solution so I thought a Generic approach would be best, until I saw how Silverlight serializes my object, for example:
public class Customer
{
public string Name { get; set; }
}
public class Wrapper<T>
{
}
If I have a method in my WCF service that returns a wrapped Customer ( public Wrapper<Customer> Get() ) the proxy class generated is:
a) Not a generic implementation (Wrapper<Customer> )
b) Has a very strange class name, something like WrapperOfCustomerUyenbzx
Am I doing something wrong or will I have to get used to it?
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
|
Thanks Mark, just what i expected...
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
I am attempting to save new data to a database when a user closes their browser. I have tried to put the submitchanges command in the app_exit event but I get an error that says:
Reference to a non-shared member requires an object reference.
I need to save changes on closing without requiring user input. Is there any way to achieve this from within the VB code?
any help would be greatly appreciated.
|
|
|
|
|
|
I believe that anyone who asks in this WPF programming forum, how to be invited to a completely different mailing list that most of us have not heard of, is instantly accepted as a result.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
I am sorry, but I honestly have no idea what you're talking about. If you wrote to them and they did not get back, one has to assume that you've been rejected. The alternative is to find out who is on this list, and ask them directly.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
The Disciples are a group of WPF enthusiasts who actively blog, write articles, give talks, and generally shout out about WPF and related technologies, as well as point out its deficiencies and where things need to be improved. This is a google groups list consisting of people like Josh Smith, Sacha Barber, Marlon Grech, Karl Shifflett (and me), and it's invitation only. The threads are available for anybody to view, but the discussions are limited to the members - basically those who've shown they have the inclination and experience in WPF.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
OK - they get to complain about WPF and Josh stays an MVP ? I got kicked out for complaining about stuff in public when no-one at MS would listen to me.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
It's all right - they won't even look at me for MVP status.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
*grin* I am glad to hear that WPF is an area where they are listening to criticism. I am far from the guru status that such a list would imply, but I use it daily and there's some big holes in it. And the bug I reported while it was in beta, whereby WPF cannot render images it has to resize without destroying them, is still in there. That after the bugs they ignored or insisted were features in VS2008, is when I realised that the MVP program had become a bit of a joke, at least in my neck of the woods.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|