View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0002521 | NoesisGUI | C# SDK | public | 2023-02-23 17:06 | 2023-03-01 10:38 |
| Reporter | voula_d | Assigned To | sfernandez | ||
| Priority | normal | Severity | major | ||
| Status | resolved | Resolution | no change required | ||
| Product Version | 3.1.7 | ||||
| Summary | 0002521: Adding controls to canvas dynamically not working | ||||
| Description | I'm trying to add controls to a canvas by dynamically loading xaml. But no controls are added to the canvas, or rather I can see that they are added as Children but never get rendered. I get the following error in the output: Null item added to UIElementCollection. The following link contains code that reproduces the issue. https://drive.google.com/file/d/1XU4QjiElK47VUMmFRtn2_j2yXBDbcFxS/view?usp=sharing | ||||
| Platform | Any | ||||
|
The error message indicates that you are trying to add a null object to the UIElement collection. using UserControl = Noesis.Portability.NoesisUserControl; And the xaml you are dynamically loading is a plain UserControl, but when adding it to the Canvas you are casting to NoesisUserControl (because of the type redefinition), so the cast returns null. Changing the cast to UIElement for example will fix it: theCanvas.Children.Add(child as UIElement); |
|
|
You are absolutely right and I am sorry for the silly mistake. The sample now works but our production scenario is a lot more complex and it still does not work as expected, i.e. controls are not added to the canvas dynamically. I will try to reproduce our problem again and will get back to you. Thank you. |
|
|
Marking this as solved. If necessary, please, open a new ticket with a more specific problem. |
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2023-02-23 17:06 | voula_d | New Issue | |
| 2023-02-23 19:31 | sfernandez | Assigned To | => sfernandez |
| 2023-02-23 19:31 | sfernandez | Status | new => assigned |
| 2023-02-23 19:40 | sfernandez | Status | assigned => feedback |
| 2023-02-23 19:40 | sfernandez | Note Added: 0008303 | |
| 2023-02-24 09:37 | voula_d | Note Added: 0008305 | |
| 2023-02-24 09:37 | voula_d | Status | feedback => assigned |
| 2023-03-01 10:38 | jsantos | Status | assigned => resolved |
| 2023-03-01 10:38 | jsantos | Resolution | open => no change required |
| 2023-03-01 10:38 | jsantos | Note Added: 0008317 |