|
Application.Current.RootVisual will get you the top level element from
anywhere in the code.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
And the codebehind too? Ok, thank you, when i finish my work time i will prove it 
|
|
|
|
|
javixuwi wrote: And the codebehind too?
Yes. There's no difference between the code-behind code and
the code produced from XAML
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi, this is my first post in this forum. Codeproject is a good source for nearly everything i need.
I use Visual Studio 2008 SP1 and have Silverlight 3.
I made: new project -> C# -> Silverlight Application
I have to read a xml-file and i wanted to use the XmlReader-class:
XmlReader xmlReader = XmlReader.Create(@"C:\Dokumente und Einstellungen\THI\Desktop\stage2.xml");
An Exception occured: file is not in the xap-package try to use fetching the file with HttpWebRequest. (something like this)
I tryed to make this example work:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest(VS.95).aspx#Mtps_DropDownFilterText[^]
I dont understand how to write the RequestState class and i dont understand what is: allDone.WaitOne() or allDone.Set()
Is here anybody who can explain this?
I tried to write RequestState class:
public class RequestState : IAsyncResult
{
private HttpWebRequest myRequest = null;
public HttpWebRequest Request
{
get { return myRequest; }
set { myRequest = value; }
}
private HttpWebResponse myResponse = null;
public HttpWebResponse Response
{
get { return myResponse; }
set { myResponse = value; }
}
private Stream myStream = null;
public Stream StreamResponse
{
get { return myStream; }
set { myStream = value; }
}
private byte[] ReadBuffer = new byte[1024];
public byte[] ReBuffer
{
get { return ReadBuffer; }
set { ReadBuffer = value; }
}
private StringBuilder myStringBuilder = new StringBuilder();
public StringBuilder RequestData
{
get { return myStringBuilder; }
set { myStringBuilder = value; }
}
}
Greetings
Thi
|
|
|
|
|
First - your URI @"C:\Dokumente und Einstellungen\THI\Desktop\stage2.xml"
is not going to work. Silverlight runs on the client and does not allow
direct access to the client's file system without asking the user first,
using the OpenFileDialog class.
The XmlReader.Create() method that takes a URI string only works for files
packaged in the Silverlight application's XAP file.
If the XML file you need to open is on the client's computer, you
need to use OpenFileDialog, not HttpWebRequest.
So where is the XML file you need to load?
Thi**01 wrote: I dont understand how to write the RequestState class and i dont understand what is: allDone.WaitOne() or allDone.Set()
All web requests in Silverlight are asynchronous. That means
the request is sent, processing continues, and at some later time
when a reply is received, the app is notified.
The example code you linked to uses an EventWaitHandle to wait
on the requesting thread until the reply is received, then continues
processing, essentially making the web request synchronous. IMO
it's a bad example - a reply could take many seconds, so if the
request is made on the UI thread, you've halted the UI thread,
which could lead to a bad user experience.
allDone is an EventWaitHandle or one of its derived classes, so if
you're new to threading, you may want to look at that documentation.
The RequestState can be anything you want - an existing object of any
class. Its purpose is to allow you to pass something across the asynchrounous
call. Whatever object you pass in the request will be available to you in the
reply.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Thanks, im at work now and going to try your tips, then i post again!
|
|
|
|
|
The tip with the WebClient worked for me.
I will explain what the point was.
You have to know this:
http://msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx[^]
What this text says is, that the Silverlight-Runtime looks first for a certain security-file when a resource is called from a server: the clientaccesspolicy.xml. When this file is not correct or not there at all then a security exception is thrown.
The problem was:
This file was not there so i had to put i manually on my localhost.
(I have apache. The clientaccesspolicy.xml has to be put in the htdocs folder.)
clientaccesspolicy.xml :
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from>
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
This is my Silverlight App :
public void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
Debug.WriteLine(e.Result);
}
public void XmlReadTest()
{
Uri url = new Uri("http://localhost/stage2.xml",UriKind.Absolute);
WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(url);
}
Nice Closing Time
|
|
|
|
|
|
The Invoke method in WPF was moved to the Dispatcher object, which can be accessed via the Dispatcher property on the TextBox.
|
|
|
|
|
thank you very much
I was really confused
|
|
|
|
|
|
Mohammad Dayyan wrote: I'm gonna create a MenuItem like
Kind of conflicts with
Mohammad Dayyan wrote: Could you please guide me how I should do it ?
doesn't it?
Try, when you have a specific problem post your code and someone will probably help
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
I have a mate who has had a web site built for him, based on C# and classic ASP, it is all very amateurish and I am considering offering to rebuild the thing properly. This will be a labour of love, or at least a few beers anyway. The design requires a lot of pictures/graphics but is predominately a data driven site.
I have no experience at all with WPF and Silverlight although I have started working through a book and I have built a number of ASPX sites. Also I am a lousy UI designer, I'm the great proponent of battleshit grey.
So, should I use it to learn Silverlight or just stick to ASPX. Professionally I am a winforms LOB developer so there will be limited professional benefit.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
There's a significant learning curve if you're new
to WPF/Silverlight, although since you know .NET
already, it lessens the pain a bit.
Unlike ASP/ASP.NET, Silverlight apps run on the client. This allows
for much richer user experience on the client end that you can't get
from static HTML pages, and you get to use familiar language like C#/VB.NET.
When Silverlight is hosted in an ASP.NET web app, you can
then have processes running on both the server and the client.
If that is something you can (or need to) leverage to make
the site better and the learning curve is worth the time,
then go for it.
Otherwise, I would think ASP.NET would be a good option.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It turns out there are mild time constraints so I may save the SL for version 2. Thanks for your input Mark
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi friends i use wpf Datagrid.
<br />
<Custom:DataGrid VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" EnableRowVirtualization="True" SelectionUnit="FullRow" RowBackground="Aqua" AlternatingRowBackground="Beige" IsReadOnly="True" SelectionMode="Extended" AutoGenerateColumns="False" Background="White" FontWeight="Bold" FontFamily="Arial" FontSize="10.667" Height="Auto" x:Name="dgChronicDiagnosis" HorizontalGridLinesBrush="{x:Null}" VerticalScrollBarVisibility="Auto" MinHeight="0" VerticalGridLinesBrush="{x:Null}" GridLinesVisibility="None" RowDetailsVisibilityMode="Collapsed" BorderBrush="{x:Null}" ColumnHeaderStyle="{DynamicResource DataGridColumnHeaderStyle}" RowStyle="{DynamicResource DataGridRowStyle1}" BorderThickness="0" Margin="0,4,0,0" VerticalAlignment="Center" VerticalContentAlignment="Stretch" IsSynchronizedWithCurrentItem="True" AreRowDetailsFrozen="True"><br />
<Custom:DataGrid.Columns><br />
<br />
<br />
<Custom:DataGridTemplateColumn Header="OnSet" Width="10*" CellStyle="{DynamicResource TempDataGridCellStyle}" ><br />
<Custom:DataGridTemplateColumn.CellTemplate><br />
<DataTemplate ><br />
<TextBlock Text="{Binding ONSET}" FontFamily="Arial" FontSize="10.667"/><br />
</DataTemplate><br />
</Custom:DataGridTemplateColumn.CellTemplate><br />
</Custom:DataGridTemplateColumn><br />
<br />
</Custom:DataGrid.Columns><br />
</Custom:DataGrid><br />
Now when i bind the Data grid with list having one record there i lot of white space as record increases the space also increases
WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP
|
|
|
|
|
|
|
|
I can't get u Abinav.Could you just give me the code.Thanks
|
|
|
|
|
|
Sample is fine.But,it wont find out if u enter numerics in text column.I need the entire code for that.When I click the button,it should check the values in textboxes and it should display.Could u help me?thanks
|
|
|
|
|
|
The samples you've been shown show how you can use Silverlight
validation.
You can change the samples to fit your needs.
You could loop through the strings using Char.IsDigit()/Char.IsLetter().
You could also use regular expression matching
bool isalldigits = Regex.IsMatch(inputstring, @"^([0-9]+)$");
bool isallletters = Regex.IsMatch(inputstring, @"^([a-zA-Z]+)$");
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|