c# - Property setter trims a value assigned from LINQ, but isn't displayed as such in WPF datagrid -
I am using ODBC from LINQ to project results of a query, saved in an XML file, In custom object Custom object contains string property, "pfrequency." Its setter value is assigned, if the value is not zero. I have opened my XML file and confirmed this work (the value of the property is to be sorted).
However, when the custom object is deserialized and displayed in a WPF datagrid, the DataGridComboBoxColumn column value is empty for my property. The columns items are bound to a static resource of the source string, which includes the value assigned to my custom object's pequared property. So, why does not my value appear in the datagrid?
Pequiquancy property:
[XmlElement (IsNullable = true)) Public string pequarqancy {receive this.payFrequency; } Set {if (value! = This.payfrequency) {this.payFrequency = (value ?? value.Trim ()); NotifyPropertyChanged ("PayFrequency"); }}}
WPF datagroup column:
& lt; Datagrid combo box column header = "pay frequency" selected ITMBID = "{Compulsive XLGommentation. Pay Frequency, Mode = To Y}" ItemSource = "{Binding Source = {Static Resource Exlude Pay Frequency String}}" /
Item source from the WPF DataGrade column:
& lt; X: array type = "{x: type sys: string}" x: key = "xlgoPayFrequencyStrings" & gt; & Lt; Sys: string & gt; APM & lt; / Sys: string & gt; & Lt; Sys: string & gt; APQ & lt; / Sys: string & gt; & Lt; Sys: string & gt; OD & lt; / Sys: string & gt; & Lt; Sys: string & gt; NP & lt; / Sys: string & gt; & Lt; / X: array & gt; An important point: If I trim the value in my LINQ query instead of handling the property property of my custom object, the value is displayed correctly in the WPF datagrid column. . But, as I said, when I look at the custom object serial made to XML, there is no white space in the value of the property. Here are my band-aids fixes (excerpts from my LINQ query):
Pfrequency = xcom ["pay_freq"]. ToString () Trim ()
Thanks for any help! I keep the manipulation of values in a lot of space, instead of handing over my custom object to the object, rather than cleaning somewhere else!
This line is not correct. It will try to trim only value
if it is empty, which will create a runtime exception ...
this.payFrequency = (value ?? value.Trim) );
One way to trim it is only when it is not empty, instead it is to use the ternary operator ...
if ( Value! = This.payFrequency) {This.payFrequency = (value == empty? "": Value.Trim ()); NotifyPropertyChanged ("PayFrequency"); }
Comments
Post a Comment