Exactamente me refería a eso PeterPay.
Pongo el codigo del createTemplate a ver si dais con el problema.
Muichas gracias de antemano, y creo que este problema se tendrá que ir resolviendo de día a día, porqué veo que la mayoría sois del otro lado del Atlántico (soy español).
Ahí va:
Código:
private XElement CreateTemplateXaml()
{
XElement newXaml = XElement.Parse(OriginalXaml.ToString());
foreach (Control ctrl in GetChildControls<IReportElement>())
{
// find the existing XAML for the child control
XElement element = (from el in newXaml.Descendants()
from attr in el.Attributes()
where attr.Name.LocalName.ToLower().Equals("uid") &&
attr.Value.Equals(ctrl.Uid)
select el).FirstOrDefault();
var canvasXaml = newXaml.Descendants(TemplatesManager.WpfNamespace + "Canvas").FirstOrDefault();
// if the control was added since the last save...
// this assumes that the only way an element can be added is if it is Canvas-based
if (element == null && ctrl is IReportElement)
{
var reportElement = ctrl as IReportElement;
if (canvasXaml != null)
{
// create the XAML for the new control
element = new XElement(TemplatesManager.SdfLibraryNamespace + reportElement.GetType().Name);
element.Add(new XAttribute("Uid", ctrl.Uid));
// add the new XAML to a copy of the original XAML
canvasXaml.Add(element);
}
}
if (element != null)
{
IReportElement re = ctrl as IReportElement;
// replace the existing properties
element.Descendants().Remove();
element.Add(re.XamlProperties);
// update all the attributes
foreach (XAttribute newAttr in re.CreateAttributes())
{
XAttribute oldAttr = (from attr in element.Attributes()
where attr.Name == newAttr.Name
select attr).FirstOrDefault();
if (oldAttr != null)
oldAttr.Remove();
element.Add(newAttr);
}
}
}
return newXaml;
}
Pues creo que es aquí donde falla todo, no recordaba como se hizo el código(he heredado el proyecto de otra persona así por las buenas y me viene grande en algunos aspectos)