|
Hi,
In WPF, I can set Image with a photo, and can see when I load the page. However, if I want to set that through a code-behind, I cannot. Here is my code, do you find anything wrong in it that might cause this problem? I checked on compile time, and there is no problem in the location of myPhoto.png.
> string location = @"C:\myPhoto.png";
> Uri uri= new Uri(location,> UriKind.Relative);
> ImageSource imgSource = new BitmapImage(uri);
> Icons.Source = imgSource;
> Icons.Width = 10;
>Icons.Height = 10;
> Icons.Visibility = Visibility.Visible;
thanks,
|
|
|
|
|
Maybe try
C:/ myPhoto.png
Or
File://C:/myPhoto.png
The UriKind should be Absolute as well.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: The UriKind should be Absolute as well.
When I made that mistake, I remember getting a compiler error. I was using "/AssemblyName;component/Images/filename.png", and still had to use Absolute.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
That's an absolute address though, isn't it?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I wouldn't think so. I would think an absolute address would be a fully qualified path, and the one I use would be relative to the named assembly.
I guess it's a matter of perception.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
paradisonoir wrote: > string location = @"C:\myPhoto.png";
> Uri uri= new Uri(location,> UriKind.Relative);
That's an absolute path, not a relative one.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hey! I'm working this side of the street
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
ROTFL !!!
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi. I am trying to apply drawing brushes on a 3D model (cube) in Blend. What happened is that I managed to apply my drawing brushes on two opposite sides of the cube, but when trying to apply my brushes to the other sides they simply disappear.
Is anyone there came across this problem and what is the solution?
Thanks,
David
|
|
|
|
|
I have spent a few days looking now, and have had no luck, but i thought i would ask here incase any one else knew something i have missed. Is it possible to interact with msOffice applications through a silverlight website.
I'm looking for the ability to create word and or excel documents programatically then launch them in word or excel. Infragistics have a component that lets you import/export data from excel, as do several other component providers, but i have not yet seen any tutorials/documentation on how this is done, any help or pointers would be appreciated.
|
|
|
|
|
|
I take it the answer will be the same for intergrating with outlook too, which is a lot harder to do using web services/applications as they would need to be hosted on the PC viewing the site. The office stuff may be acceptable server side but any outlook interaction would have to be client side.
|
|
|
|
|
Silverlight is a browser plugin so it's pretty limited - no playing outside the
browser sandbox
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Just send a web service request to the server with your parameters for the word/excel file, have the server create the file. The web request can bring back a temporary URL with the desired file that you would link to in a popup window.
|
|
|
|
|
Hi
Here's another simple question. I'm a newbie to WPF and I want to bind some data to a combobox. The data is coming from a Typed Dataset which I added via the VS2008 wizard.
Firslty, I instantiate the DataAdapter and the DataTable:
dsParrys_offoice_furnitureTableAdapters.ProductRangeTableAdapter daProductRange;
dsParrys_offoice_furniture.ProductRangeDataTable dtProductRange;
Then I fill the DataTable dtProductRange:
daProductRange = new aXYZ.dsParrys_offoice_furnitureTableAdapters.ProductRangeTableAdapter();
dtProductRange = daProductRange.GetData();
this.DataContext = dtProductRange;
I then want to display all the ProductRangeDescription in the listbox so I do the following:
cboStartupNew.ItemsSource = dtProductRange;
cboStartupNew.DisplayMemberPath = dtProductRange.Columns[1].ToString();
cboStartupNew.SelectedValuePath = dtProductRange.Columns[0].ToString();
cboStartupNew.SelectedValue = dtProductRange.Columns["ProductRangeDesc"];
When I enter debug mode and hover my mouse over cboStartupNew (tho combobox) it says that there are 17 items in the combobox, but still nothing displays in the combobox. Any ideas?
I tried using cboStartupNew.ItemsSource = ((IListSource)dtProductRange).GetList() as wellm but still no luck
|
|
|
|
|
What does your data template look like? There are much easier ways to display things in WPF, and it looks as though you are trying to use ASP.NET techniques rather than using the power of binding and templating 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
|
|
|
|
|
I'm not using a DataTemplate. I was under the impression that the binding will work even without one.
|
|
|
|
|
Hi,
I am working on a WPF application. In this I have a listview as
<ListView Height="271" HorizontalAlignment="Right" Margin="0,52,12,0" Name="lstvHistory" VerticalAlignment="Top" Width="181">
<ListView.View>
<GridView >
<GridViewColumn Header="Type" Width="50" />
<GridViewColumn Header="Description" Width="130"/>
</GridView>
</ListView.View>
</ListView>
In this dynamically I have to add one row at a time and later again one more row like that..
In this I have to add different data to the two columns of a row dynamically. For example for the first column I have to add 'MOVE' and second column 'LEFT' like this.
Please if any one have any idea how to do this please reply me.
|
|
|
|
|
You can create an appropriate data type (class) to hold the data.
Then you can bind the ListView to a collection (an ObservableColection<>
is a good coice here). Once you have that, you could use the DisplayMemberBinding
property of GridViewColumn to have the columns display the desired data from
your data type, for example
<GridViewColumn Header="Type" Width="50" DisplayMemberBinding="{Binding Path=Type}" />
<GridViewColumn Header="Description" Width="130" DisplayMemberBinding="{Binding Path=Description}" />
When you dynamically add or remove objects from the collection, rows will be added
or removed from the ListView.
Lots of info and examples here: Data Binding[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I am developing one application in that I have more than 20 media elements.Here is the example for 5 media elements mp1,mp2,mp3,mp4,mp5.
And i am using i value from 1 to 20 based on the i value i have to use that corresponding media element.If i value is 2 i have to use mp2 and assign path to that mp2 source from code behind.
Those all media elements are created by default through design.Please can anybody help me how to resolve this problem or any suggestions to achieve this task.
Thanks in Advance
Pavani
|
|
|
|
|
Store references to each media element in a collection or array.
If they are stored in order, you can simple use an index to access
the references.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Merk thank you for your response.Can you please explain me clearly how to create references for media elements and how to store those references in array or collection because i am new to develpoment.
|
|
|
|
|
Here's two examples, using two different types of collections...
Using a Dictionary<>
using System;
using System.Collections.Generic;
using System.Windows.Controls;
Dictionary<int, MediaElement> mediaElementDictionary = new Dictionary<int, MediaElement>();
mediaElementDictionary.Add(1, mp1);
mediaElementDictionary.Add(2, mp2);
...
int i = 1;
MediaElement mediaelement;
if (mediaElementDictionary.TryGetValue(i, out mediaelement))
{
}
Using a List<>
using System;
using System.Collections.Generic;
using System.Windows.Controls;
List<MediaElement> mediaElementList = new List<MediaElement>();
mediaElementList.Add(mp1);
mediaElementList.Add(mp2);
...
int i = 1;
MediaElement mediaelement = mediaElementList[i - 1];
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark, Thank you very much for your clear explanation.I solved my problem through your explanation.Now I got how to use media element references using list and dictionary.
|
|
|
|
|
Hi,
I am developing one application in that I have more than 5 media elements.
I want to assign path to media element source from database.For that I have created one silverlight application and there is a ClientBin in silverlight website, I have saved my uploaded videos in clientbin and that path in database.
But from code behind if i assign the path its not showing anything.
my sample code is
mplayer.Source = new System.Uri(@"D:\sample\sample.Web\ClientBin\Lake.wmv", UriKind.Absolute);
Can you please tell me is there any other way to assign path to source property or what is the mistake I have done in that code.
Thanks in Advance
Pavani
|
|
|
|