|
hi, i have used the code like the way u said, still its not running the code inside it(if Condition)...
Directive lstdir = new Directive { DirectiveName = txtDirectiveName.Text.Trim(), DirectiveDescription = txtDirectiveDescription.Text.Trim() };
if (txtDirectiveName.Text != lstdir.DirectiveName && txtDirectiveDescription.Text != lstdir.DirectiveDescription)
{
MessageBox.Show("Execute");
}
else MessageBox.Show("Duplicate Data")
|
|
|
|
|
Hello,
I have a UserControl that exposes a Selection property:
public partial class FeatureSelectionControl : UserControl
{
public string[] Selection
{
get { return (string[])GetValue(SelectionProperty); }
set { SetValue(SelectionProperty, value); }
}
public static readonly DependencyProperty SelectionProperty =
DependencyProperty.Register("Selection", typeof(string[]), typeof(FeatureSelectionControl), new UIPropertyMetadata(new string[] { }));
I want to use it in a window and bind the control's property to one of the window's properties:
<Window Name="Window" ...>
<local:FeatureSelectionControl Selection="{Binding ElementName=Window,Path=CustomerGroups}" ...>
</local:FeatureSelectionControl>
Code behind:
public partial class WindowCounterpartyGroupRiskReview : Window
{
public WindowCounterpartyGroupRiskReview()
{
CustomerGroups = new string[] { };
InitializeComponent();
}
public string[] CustomerGroups { get; set; }
This crashes with a "first chance exception of type 'System.NullReferenceException' occurred in PresentationFramework.dll Additional information: Object reference not set to an instance of an object". STack trace is:
PresentationFramework.dll!System.Windows.Markup.BamlRecordReader.ProvideValueFromMarkupExtension(System.Windows.Markup.MarkupExtension markupExtension = null, object obj = {System.Windows.Markup.BamlCollectionHolder}, object member = null) + 0x52 bytes
PresentationFramework.dll!System.Windows.Markup.BamlRecordReader.ReadPropertyArrayEndRecord() + 0x5f bytes
PresentationFramework.dll!System.Windows.Markup.BamlRecordReader.ReadRecord(System.Windows.Markup.BamlRecord bamlRecord) + 0x636 bytes
PresentationFramework.dll!System.Windows.Markup.BamlRecordReader.Read(bool singleRecord = false) + 0x1c bytes
PresentationFramework.dll!System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment() + 0xc9 bytes
PresentationFramework.dll!System.Windows.Markup.TreeBuilder.Parse() + 0xf bytes
PresentationFramework.dll!System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream stream, System.Windows.Markup.ParserContext parserContext, object parent, bool closeStream) + 0xc7 bytes
PresentationFramework.dll!System.Windows.Application.LoadComponent(object component, System.Uri resourceLocator) + 0x16e bytes
> CRRT.exe!CRRT.WindowCounterpartyGroupRiskReview.InitializeComponent() Line 1 + 0xb bytes C#
However, when I change my code and make the property a mere string, I don't get an exception and everything works as expected.
Any idea ?
|
|
|
|
|
Ok I found the solution here: use a List<string> instead of a string[].
|
|
|
|
|
Hello,
I'm having some difficulty retrieving JSON formatted data returned from a remote server. I'm using Silverlight 4 in VS 2010. My code is as follows:
byte[] response = new byte[32768];
SocketAsyncEventArgs e = new SocketAsyncEventArgs();
e.SetBuffer(response, 0, response.Length);
soc.ReceiveAsync(e);
string data = Encoding.UTF8.GetString(e.Buffer, e.Offset, e.BytesTransferred).Trim(new char[] { '\0' });
If I uncomment the call to Sleep for 4 or 5 seconds, then my string variable "data" populates consistently. However, if I don't Sleep, then after a few times of receiving updates, the variable "data" is consistently empty (although there is data in the buffer). Basically, I have to slow the whole process down in order to get my updates. That's not an acceptable solution though, as I'm dealing with market data which needs to be processed in real-time.
Incidentally, nearly identical code works without the call to Sleep in a console app I wrote against the same remote server. In that case, the following works perfectly:
byte[] snapBytes = new byte[32768];
soc.Receive(snapBytes);
String data = Encoding.ASCII.GetString(snapBytes).Trim(new char[] { '\0' });
Thanks in advance for any thoughts or ideas.
|
|
|
|
|
Well, yeah...
Do you understand what the "Async" in "ReceiveAsync" is supposed to do? Its an asynchronous function meaning its non blocking. So when you call soc.ReceiveAsync() it IMMEDIATELY goes to the next line and the buffer will be filled to a random length depending on millions of things.
This is used so you don't hang your GUI and don't need to handle multi-threading yourself.
You need to wait til the call is *really* done. For instance, by subscribing to the SocketAsyncEventArgs.Completed event .
|
|
|
|
|
Hello,
Anyone can tell me advantages using PRISM in Silverlight.
And Which design pattern is suitable for PRISM....Its MVVM?
Thanks & Regards...
|
|
|
|
|
|
Code Project author and Prism team member Karl Shifflett has literally written the book on Prism development. Check out his blog[^], and order the book.
|
|
|
|
|
MVVM does complement Prism.
Prism give you an opportunity to work in a more decoupled UI / code environment while giving you necessary framework features to call these framework features.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Hi,
I have just started learning WPF and exploring more on WPF controls.
Can any one help how to display popup? I have used TextBlock under popup control as below :
<pre> <Popup StaysOpen="True">
<TextBlock Name="txtBlock1">
This is simple PopUp in WPF..
</TextBlock>
</Popup></pre>
But how to trigger this popup?
Thanks and regards,
Rahul Chitte
|
|
|
|
|
Popups are shown with the IsOpen method.
|
|
|
|
|
Two ways:
1) Give it a name (The Popup itself, not just the TextBlock), and open it in the code-behind
2) (The preferred method) Bind the Popup's IsOpen property to something else, such as a toggle button or a boolean field on your underlying model.
|
|
|
|
|
This sample [^]could help you out.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
That's a good example!
People with high attitude deserve the standing ovation of our highest finger!
My Blog![ ^]
|
|
|
|
|
Thank you Tarun.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
OK; I have digested the depressing news I got in my "Data Access for Dummies" thread below and accepted that I need to create a Silverlight 4 client app and a WCF host service that supplies the data.
SFSG!
Of course, I want to create a common class library containing the DTO class definitions so that the host and the client can share the same definitions.
BUT!!! If I create a Silverlight class library, I can't use Ado objects to access the db (which I want to do), and if I create a "normal" windows class library, I can't reference it in my Silverlight client app.
So how can I do that???
Beidh ceol, caint agus craic againn - Seán Bán Breathnach ----- Don't tell my folks I'm a computer programmer - They think I'm a piano player in a cat house... ----- Da mihi sis crustum Etruscum cum omnibus in eo! ----- Everybody is ignorant, only on different subjects - Will Rogers, 1924
|
|
|
|
|
Do you know how WCF works? I'm not being funny, I'm just trying to find a common basepoint here. If you have your Silverlight app needing to know about Ado types, then you have just put a hard dependency in which means that your service could not be consumed by other types of systems (such as Java ones) that have no knowledge of the Ado types.
You create your model as a DataContract. Here's an example:
namespace WcfServer
{
using System;
using System.Runtime.Serialization;
[DataContract]
public class Customer
{
[DataMember]
public string Forename { get; set; }
[DataMember]
public string Surname { get; set; }
[DataMember]
public DateTime DateOfBirth { get; set; }
[DataMember]
public int Id { get; internal set; }
}
} As you can see, it's POCO. Now, the point here is that you don't add this as a class library into your Silverlight application. What you do, is import the service reference into your Silverlight application, so it gets access to the contract (and all the other gubbins it needs, such as the OperationContract ). You now have a nice separation in place which means that you can leverage things such as web farms to manage scalability of your service.
As you are new at this, I would recommend buying a book and reading up on this. There's a lot to it, and it's well worth the investment. The book I usually recommend for Silverlight is Silverlight 4 Unleashed[^] by MVP and Mix speaker, Laurent Bugnion.
|
|
|
|
|
All this is quite new to me, I've never used neither Silverlight nor WCF before and my knowledge about those techniques is quite limited, hence the stupid questions.
Thanks for having patience with me, though. I get your point above to a certain point. But isn't it so (with reference to your example) that the Customer class with its DataContract attributes needs to be defined and have identical definitions on both sides of the WCF wall? That is at least what I seem to recall having read somewhere.
Thanks for the book recommendation. I actually ordered that very book yesterday. But since it's going to take some time for it to arrive, I thought I'd get going by asking stupid questions in this Forum in the meanwhile...
Beidh ceol, caint agus craic againn - Seán Bán Breathnach ----- Don't tell my folks I'm a computer programmer - They think I'm a piano player in a cat house... ----- Da mihi sis crustum Etruscum cum omnibus in eo! ----- Everybody is ignorant, only on different subjects - Will Rogers, 1924
|
|
|
|
|
Johnny J. wrote: But isn't it so (with reference to your example) that the Customer class with
its DataContract attributes needs to be defined and have identical definitions
on both sides of the WCF wall?
Yes, but when you import the service reference, that comes with it. In other words, the proxy implementation that your Silverlight service calls is created for you - that's cool.
|
|
|
|
|
So when you change somthing in your service, you need to refresh or delete/readd your service reference?
Beidh ceol, caint agus craic againn - Seán Bán Breathnach ----- Don't tell my folks I'm a computer programmer - They think I'm a piano player in a cat house... ----- Da mihi sis crustum Etruscum cum omnibus in eo! ----- Everybody is ignorant, only on different subjects - Will Rogers, 1924
|
|
|
|
|
Yes. You import the contract, which creates a proxy implementation.
|
|
|
|
|
You need to pay Pete with a 5, thats an excellent explanation. Once you get over the initial STEEP learning curve it does make some sense. I got lucky, a corporate policy that the desktop is not allowed to connect directly to a database forced us to WCF and the move to SL was a natural from there.
I create the WCF in a separate project, the bulk of it can be built by a code generator as the CRUD operations (model and DAL/controller) are very standard.
The only real drawback that I have found is that a WCF does not allow a dynamic structure. Think of query a procedure an then just throw the result at a datagirdview in winforms, this is not the way SL/WPF works, EVERY thing needs to be defined, all the properties for the proc need to be in a model and that needs to be imported into the client and then you can use it in a datagrid. There is a work around for the dynamic stuff but it is painful.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You can have a 5 both of you. Thanks a lot for the help. Right now, it does look like gibberish to me. I hope that when I get the book, things will brighten a bit...
Why can't I be applicable like John? - Me, April 2011 ----- Beidh ceol, caint agus craic againn - Seán Bán Breathnach ----- Da mihi sis crustum Etruscum cum omnibus in eo! ----- Everybody is ignorant, only on different subjects - Will Rogers, 1924
|
|
|
|
|
Mycroft Holmes wrote: WCF does not allow a dynamic structure
Excellent point. You're right that you can get round it, but the effort of doing so doesn't justify the development needed to do it. I've been playing around with parsing dynamic ODATA structures, and it's just so much boilerplate and jiggery pokery that I'm seriously wishing I hadn't started it.
|
|
|
|
|
I use a structure from Telerik, return the data as xml to the client then parse it into the table/colum/row collections, this then dinds to the Telerik datagrid and I have a data dump utility from any stored proc.
Never underestimate the power of human stupidity
RAH
|
|
|
|