Hello world!
I've got a checkboxlist binded to an XML doc via an XMLDataProvider. With this I can fill some attribute of my checkbox like "isChecked", "isEnabled" and the "Tag" propertie.
I made a function "chkCheck" called when the user checks in a checkBox. This fonction has to recover the tag of the checkBox. The problem is that the type returns is an XMLAttribute. I can't convert it into an integer.
I have seen the XMLConvert class without success.
Anyone got an idea? Thanks
Loading
yohannPosted Aug 4, 2008, 6:59 AM
I solved the problem. I just have to cast my chk.Tag into an XMLAttribute...
Thanks to you, have a good day
yohannPosted Aug 4, 2008, 6:00 AM
it's strange because I can't ask to the value property of the XMLAttribute. In fact when I unCheck my checkbox, I want to recover the tag propertie. At this moment it raise the error "cannot convert type system.xml.xmlAttribute" to "system.string". Here is my function.
private void UnCheck(object sender, RoutedEventArgs e)
{
CheckBox chk = (CheckBox)sender;
int layerIndexUnChecked = int.Parse(chk.Tag) ;
}
Don't you think it's come from that i bind my checkboxlist with a XMLDataProvider and I bind the element with "XPath"? Before using the xmlDataProvider I used a dataset and this problem didn't raise...
AlanPosted Aug 4, 2008, 5:41 AM
If you mean that you're trying to convert the 'value' of the XmlAttribute to an int, then try:
int val = int.Parse(xmlAttribute.Value);
However, this will only work if the value is the string representation of an integer. If it's "true" or false" and you want to convert it to 1 or 0 respectively, then try:
int val = (xmlAttribute.Value.Trim().ToLower == "true") ? 1 : 0;