|
|
I'm currently trying to grab data by using C Sharp with the Silverlight Framework. The request does not seem to go through though because I'm trying to pull data off a website that appears to use .NET and uses a postback to return the information.
I'm using the following method to try and submit the request:
GlobalVariables.client.UploadStringAsync(new Uri(GlobalVariables.stopRequestUri), "__EVENTTARGET=&__EVENTARGUMENT=&txtSearch=springfield+and+busey&cmdSubmit=Search");
stopRequestUri = http://stopwatch.cumtd.mobi/Default.aspx?__ufps=841248 and client is of type WebClient
When I've used Fiddler to check how the request is going through, it can execute the request just fine and appears to include some sort of redirect. I can't seem to get my own code to do the same thing.
I'm pretty much trying to submit the form with something like Springfield and Busey and then have it bring up the bus stop times for that intersection just like it would appear in the web browser.
Any ideas?
|
|
|
|
|
Hi folks!
Is there a way to do some preloading of images in WPF?
My Image has an URI as source (a URI property implementing INotifyPropertyChanged in the code behind)
When I create the URI (points to a network share) and fire the NotifyPropertyChanged Event, my application freezes for a second or two.
So how can I preload the image so the applicatio won't freeze?
Here's some code:
XAML:
<Image Source={Binding Path=Image_1, NoitifyOnSourceUpdated=True}/>
And the CB:
public DataContextClass : INotifyPropertyChanged
{
private Uri image_1;
public Uri Image_1
{
get
{
}
set
{
image_1 = value;
PropertyHasChanged("Image_1");
}
}
void Timer_Elapsed(object sender, EventArgs e)
{
Image_1 = CreateUri(GetFilePathFromNetworkShare());
}
}
Thanks in advance!
eza
|
|
|
|
|
I would tend to read the data in using a background worker and marshall the image back to the UI thread once it's been read in. Whenever you see a UI that's stopped responding, you're seeing one that needs to have some threading in place.
"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
|
|
|
|
|
That's true, for sure - but as a matter of fact up to now wpf is doing the black magic (inclluding the dispatching), I'm just passing an uri.
Can this be done with some sort of lazy loading (heard once of that during a dev training) or other obsurce xaml tags?
Or is creating an image out of the uri (including the preloading) and passing it to the xaml as imagesource the better way? Won't the problem keep existing as the dispatcher has to deal with the pictures and their transformation-rotation anyway?
|
|
|
|
|
Have you tried WritableBitmap? you can return a empty WritableBitmap, start a thread to load your URI, then when the loading is finished, update it back through Dispatcher :
writeBitmap.Dispatcher.Invoke(DispatcherPriority.Background,
new ThreadStart(delegate
{
//UI Thread
Int32Rect outRect = new Int32Rect(0,
(int)(writeBitmap.Height - height) / 2, width, height);
writeBitmap.WritePixels(outRect, bits, stride, 0);
}));
Thats what I did for my FileToIconConverter.
|
|
|
|
|
I have an image lock.png beside of my WPF exe file in the images folder. Now, I'm gonna load it into the WPF Project as an image.
I've used the following XAML code:
<Image Stretch="Fill" Source="pack://siteoforigin:,,,/images/lock.png" />
It works, but Expression Blend or Visual Studio doesn't show it when I'm working on the project.
How can we show external images in these situations?
|
|
|
|
|
Hi,
I have an image lock.png beside of my WPF exe in the images folder.
Now, I'm gonna load it into the WPF Project as the App's icon, I've use the following XAML code, but it doesn't work :
Icon="images\lock.png"
How should I load an external image into a WPF application?
Thanks
|
|
|
|
|
|
|
REPOST - this question has also been put in the Q&A section.
|
|
|
|
|
Dear friends,
i am new to wpf and i got some doubt ,
i have class like these
public class FileSystem
{
Drive[] m_Drive;
public Drive[] Drives
{
get { return m_Drive; }
}
}
public class Drive
{
public string DriveName { get; set; }
Directory[] m_Directory;
public Directory[] Directories
{
get { return m_Directory; }
}
}
public class Directory
{
public string DirectoryName { get; set; }
File[] m_Files;
public File[] Files
{
get { return m_Files; }
}
}
public class File
{
public string FileName { get; set; }
}
now i want to represent these in treeview control, how to do that?
can some one give me the XAML with (binding and explanation)
Thank you
Joe
|
|
|
|
|
Have a read (and play about) with the code that Josh Smith put together here[^].
"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
|
|
|
|
|
Thank for the reply,
i saw that sample , It was in MVVM patten .. i do not want anyting like that ... if i want to bind in simple way how to do that?
|
|
|
|
|
That is the simple way. Don't try and complicate things for yourself.
"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
|
|
|
|
|
Dear Josh,
I went thru your article and many more articles for bindinf a tree view with database. My problem is still unresolved.
my requirement is, I have three tables linked togather as below
1-Order table contains, partyCode and orderNo.
2-Item table contains, orderNo & ItemCode.
3-Stages table contains, orderNo, itemCode & stageCode.(Same stageCode can appear in the table for different items, but not for same Items. Items may or may not have stages. If Item has stages, then entry for such Item will be available in stage table. Otherwise not.)
I am unable to generate a tree in below manner:
Tree display
ord1
...Item1
.......stage1
.......stage2
...item2
.......stage1
.......stage2
.......stage3
...item3
...item4
...item5
...item6
...item7
...item8
...item9
ord2
……
ord3
…….
please help me in generating a tree of such type. I am using dataservices to getch the data from database.
|
|
|
|
|
|
I have the following xaml (nonessential markup removed in the interest of brevity):
<navigation:Frame x:Name="ContentFrame" >
<navigation:Frame.UriMapper>
<uriMapper:UriMapper>
<uriMapper:UriMapping Uri="/{pageName}"
MappedUri="/Views/{pageName}.xaml"/>
<uriMapper:UriMapping Uri="/FMChart/{metricID}/{orgID}"
MappedUri="/Views/FMChart.xaml?metricID={metricID}&orgID={orgID}"/>
</navigation:Frame.UriMapper>
</navigation:Frame.UriMapper>
</navigation:Frame>
I'm creating the HyperLinkButton objects dynamically (in code), like so:
int metricID = 1;
int orgID = 1;
HyperlinkButton button = new HyperlinkButton();
button.Name = Guid.NewGuid().ToString();
button.TargetName = "ContentFrame";
<br />
<big>string url = string.Format("/FMChart/{0}/{1}", metricID, orgID);</big>
button.NavigateUri = new Uri(url, UriKind.Relative);
When I click the bbutton, the browser renders a blank page, and eventually presents me with a REALLY long stack trace (InvalidOperation exception). If I take the parameters out of th indicated line:
string url = "/FMChart";
...it works as expected (brings up the desired page).
What am I doing wrong?
SOLUTION ===========================================
It seems that the order of the UriMappers in the XAML matters. Originally the mapping I specified was the last one listed in the group. When I changed it to be the FIRST item in the group, it worked. The reason I say this is"sorta" solved is that I think this is a bug in Silverlight. It was a unique mapping (compared to all of the others) and should have been discovered by Silverlight in the original order.
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
modified on Friday, April 16, 2010 2:22 PM
|
|
|
|
|
John Simmons / outlaw programmer wrote: <urimapper:urimapping uri="/FMChart/{metricID}/{orgID}" mappeduri="/Views/FMChart.xaml?metricID={metricID}&orgID={orgID}">
Not absolutely certain, but should the Uri not be Uri="/FMChart/{metricID}&{orgID} ?
|
|
|
|
|
I tried that too, and that didn't work either. BTW, the format of the string has been represented both ways (and on the official MS site, it's the way I have it). I've trie it the following ways:
uri = "/FMChart/{metricID}/{orgID}"
uri = "/FMChart/{metricID}& amp;{orgID}"
uri = "/FMChart/{metricID}&{orgID}"
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: It seems that the order of the UriMappers in the XAML matters. Originally the mapping I specified was the last one listed in the group. When I changed it to be the FIRST item in the group, it worked. The reason I say this is"sorta" solved is that I think this is a bug in Silverlight. It was a unique mapping (compared to all of the others) and should have been discovered by Silverlight in the original order.
This is interesting.
Let me see if I get some time to play around with the navigational framework.
modified on Saturday, April 17, 2010 2:27 AM
|
|
|
|
|
Hi,
I am trying to encrypt my appSettings section through code but i am facing some problem.
This is what is am doing
-- app.config
<? xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Encrypt" value="Encrpyted"/>
</appSettings>
</configuration>
--Code
string s = System.IO.Directory.GetCurrentDirectory();
s = s + "\\Test_Encrypt_1_WPF.exe.config";
Configuration config = ConfigurationManager.OpenExeConfiguration(s);
AppSettingsSection section = (AppSettingsSection)config.GetSection("AppSettings");
if (!section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
}
config.Save(ConfigurationSaveMode.Modified);
In the above code the "section" object is showing null i.e. i am not able to find the "AppSettings" section.
I even tried configuration/appSettings but the same result.
Can anyone please help!
Thanks in advance,
Samar
modified on Thursday, April 15, 2010 6:57 AM
|
|
|
|
|
Hi All,
I got the solution myself.
Instead of
string s = System.IO.Directory.GetCurrentDirectory();
s = s + "\\Test_Encrypt_1_WPF.exe.config";
Configuration config = ConfigurationManager.OpenExeConfiguration(s);
i wrote
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
This worked!!
Regards,
Samar
|
|
|
|
|
|
Hi Mark,
I was not able to find the link you have mentioned when i was searching.
The solution in the link looks pretty similar to what i have tried.
Please do let me know if i am incorrect in any way on stating the above.
Regards,
Samar
|
|
|
|