{"action":"created","issue":{"url":"https://api.github.com/repos/LokiMidgard/NSCI/issues/13","repository_url":"https://api.github.com/repos/LokiMidgard/NSCI","labels_url":"https://api.github.com/repos/LokiMidgard/NSCI/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/LokiMidgard/NSCI/issues/13/comments","events_url":"https://api.github.com/repos/LokiMidgard/NSCI/issues/13/events","html_url":"https://github.com/LokiMidgard/NSCI/issues/13","id":332580914,"node_id":"MDU6SXNzdWUzMzI1ODA5MTQ=","number":13,"title":"SingleSelectionItemsControl - Changing the value of the selected item","user":{"login":"thecliguy","id":23440389,"node_id":"MDQ6VXNlcjIzNDQwMzg5","avatar_url":"https://avatars1.githubusercontent.com/u/23440389?v=4","gravatar_id":"","url":"https://api.github.com/users/thecliguy","html_url":"https://github.com/thecliguy","followers_url":"https://api.github.com/users/thecliguy/followers","following_url":"https://api.github.com/users/thecliguy/following{/other_user}","gists_url":"https://api.github.com/users/thecliguy/gists{/gist_id}","starred_url":"https://api.github.com/users/thecliguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thecliguy/subscriptions","organizations_url":"https://api.github.com/users/thecliguy/orgs","repos_url":"https://api.github.com/users/thecliguy/repos","events_url":"https://api.github.com/users/thecliguy/events{/privacy}","received_events_url":"https://api.github.com/users/thecliguy/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-14T22:06:24Z","updated_at":"2018-06-16T12:41:47Z","closed_at":"2018-06-16T12:40:17Z","author_association":"NONE","body":"Changing the value of the selected item results in the item no longer being selected.\r\n\r\nAttempting to programmatically select the item again (using `SelectedItem`) fails with an error: `Exception setting \"SelectedItem\": \"View of item not found Parameter name: item\"`\r\n\r\nI have built a test application in [PowerShell Core 6.0](https://github.com/PowerShell/PowerShell/releases/tag/v6.0.0-rc) to demonstrate the problem (the code can be found at the bottom of this issue):\r\n  * Press the button `Change Selected Item Value to Z`. `A` should change to `Z`.\r\n  * Press the button `Get Selected Item Index`. This should return `-1`.\r\n  * Press the button `Set Selected Item to Z`. An error occurs: `Exception setting \"SelectedItem\": \"View of item not found Parameter name: item\"`\r\n\r\n![image](https://user-images.githubusercontent.com/23440389/41440794-e0a81922-7027-11e8-8370-2d84aa961c1c.png)\r\n\r\n**To run the script you will need [PowerShell Core 6.0](https://github.com/PowerShell/PowerShell/releases/tag/v6.0.0-rc) and the paths to the five DLLs will need to be updated.**\r\n```powershell\r\n$NDPropertyDll = \"C:\\Users\\thecliguy\\.nuget\\packages\\ndproperty.core\\0.13.11\\lib\\netstandard1.3\\NDProperty.Core.dll\"\r\nAdd-Type -Path $NDPropertyDll -PassThru\r\n\r\n$NitoDisposablesDll = \"C:\\Users\\thecliguy\\.nuget\\packages\\nito.disposables\\1.2.1\\lib\\netstandard1.0\\Nito.Disposables.dll\"\r\nAdd-Type -Path $NitoDisposablesDll -PassThru\r\n\r\n$NitoAsyncDll = \"C:\\Users\\thecliguy\\.nuget\\packages\\nito.asyncex.context\\5.0.0-pre-03\\lib\\netstandard1.3\\Nito.AsyncEx.Context.dll\"\r\nAdd-Type -Path $NitoAsyncDll -PassThru\r\n\r\n$NitoTasksDll = \"C:\\Users\\thecliguy\\.nuget\\packages\\nito.asyncex.tasks\\5.0.0-pre-03\\lib\\netstandard1.3\\Nito.AsyncEx.Tasks.dll\"\r\nAdd-Type -Path $NitoTasksDll -PassThru\r\n\r\n$NsciDLL = \"C:\\Users\\thecliguy\\Documents\\Scripts\\NSCI_Tests\\NSCI-master_11-06-18\\NSCI-master\\NSCI\\bin\\Debug\\netstandard2.0\\NSCI.dll\"\r\n \r\n$Root = [NSCI.UI.RootWindow]::new()\r\n\r\n$grid = [NSCI.UI.Controls.Layout.Grid]::new()\r\n$root.Content = $grid;\r\n\r\n# Row 0\r\n$RowDefinition0 = New-Object NSCI.UI.Controls.Layout.AutoSizeDefinition\r\n$grid.RowDefinitions.Add($RowDefinition0)\r\n\r\n# Row 1\r\n$RowDefinition1 = New-Object NSCI.UI.Controls.Layout.AutoSizeDefinition\r\n$grid.RowDefinitions.Add($RowDefinition1)\r\n\r\n# Row 2\r\n$RowDefinition2 = New-Object NSCI.UI.Controls.Layout.RelativSizeDefinition\r\n$RowDefinition2.Size = 1\r\n$grid.RowDefinitions.Add($RowDefinition2)\r\n\r\n# Column 0\r\n$ColumnDefinition0 = New-Object NSCI.UI.Controls.Layout.RelativSizeDefinition\r\n$ColumnDefinition0.Size = 1\r\n$grid.ColumnDefinitions.Add($ColumnDefinition0)\r\n\r\n# Column 1\r\n$ColumnDefinition1 = New-Object NSCI.UI.Controls.Layout.RelativSizeDefinition\r\n$ColumnDefinition1.Size = 1\r\n$grid.ColumnDefinitions.Add($ColumnDefinition1)\r\n\r\n# Column 2\r\n$ColumnDefinition2 = New-Object NSCI.UI.Controls.Layout.RelativSizeDefinition\r\n$ColumnDefinition2.Size = 1\r\n$grid.ColumnDefinitions.Add($ColumnDefinition2)\r\n \r\n$btnGetSelectedItemIndex = [NSCI.UI.Controls.Button]::new()\r\n$btnGetSelectedItemIndex.Content = \"Get Selected Item Index\"\r\n$btnGetSelectedItemIndex.TabIndex = 1\r\n[NSCI.UI.Controls.Layout.Grid]::Row[$btnGetSelectedItemIndex].Value = 0\r\n[NSCI.UI.Controls.Layout.Grid]::Column[$btnGetSelectedItemIndex].Value = 1\r\n$grid.Children.Add($btnGetSelectedItemIndex)\r\n\r\n$label = [NSCI.UI.Controls.textblock]::new()\r\n$label.text = \"Selected index: \"\r\n[NSCI.UI.Controls.Layout.Grid]::Row[$label].Value = 1\r\n[NSCI.UI.Controls.Layout.Grid]::Column[$label].Value = 0\r\n$grid.Children.Add($label)\r\n\r\n$btnSetSelectedItemToZ = [NSCI.UI.Controls.Button]::new()\r\n$btnSetSelectedItemToZ.Content = \"Set Selected Item to Z\"\r\n$btnSetSelectedItemToZ.TabIndex = 2\r\n[NSCI.UI.Controls.Layout.Grid]::Row[$btnSetSelectedItemToZ].Value = 0\r\n[NSCI.UI.Controls.Layout.Grid]::Column[$btnSetSelectedItemToZ].Value = 2\r\n$grid.Children.Add($btnSetSelectedItemToZ)\r\n\r\n###$btnSetSelectedItemToD = [NSCI.UI.Controls.Button]::new()\r\n###$btnSetSelectedItemToD.Content = \"Set Selected Item to D\"\r\n###$btnSetSelectedItemToD.TabIndex = 3\r\n###[NSCI.UI.Controls.Layout.Grid]::Row[$btnSetSelectedItemToD].Value = 1\r\n###[NSCI.UI.Controls.Layout.Grid]::Column[$btnSetSelectedItemToD].Value = 1\r\n###$grid.Children.Add($btnSetSelectedItemToD)\r\n\r\n$btnChangeSelectedItemValueToZ = [NSCI.UI.Controls.Button]::new()\r\n$btnChangeSelectedItemValueToZ.Content = \"Change Selected Item Value to Z\"\r\n$btnChangeSelectedItemValueToZ.TabIndex = 0\r\n[NSCI.UI.Controls.Layout.Grid]::Row[$btnChangeSelectedItemValueToZ].Value = 0\r\n[NSCI.UI.Controls.Layout.Grid]::Column[$btnChangeSelectedItemValueToZ].Value = 0\r\n$grid.Children.Add($btnChangeSelectedItemValueToZ)\r\n\r\n$Listbox = New-Object NSCI.UI.Controls.SingleSelectionItemsControl[Object]\r\n$Listbox.TabIndex = 3\r\n$Items = New-Object System.Collections.ObjectModel.ObservableCollection[Object]\r\n$Listbox.Items = $Items\r\n\t\t\t\r\n$Items.Add(\"A\")\r\n$Items.Add(\"B\")\r\n$Items.Add(\"C\")\r\n$Items.Add(\"D\")\r\n$Items.Add(\"E\")\r\n\r\n$border = [NSCI.UI.Controls.Border]::new()\r\n$border.BorderStyle = [NSCI.UI.Controls.BorderStyle]::DoubleLined\r\n$border.Child = $Listbox\r\n\r\n$Grid.Children.Add($border)\r\n\r\n[NSCI.UI.Controls.Layout.Grid]::Column[$border].Value = 0\r\n[NSCI.UI.Controls.Layout.Grid]::Row[$border].Value = 2\r\n\r\n$btnGetSelectedItemIndex.Add_ButtonPressed({\t\t\t\r\n\t$SelectedIndex = $Listbox.Items.IndexOf($Listbox.SelectedItem)\r\n\t$label.text = \"Selected index: $($SelectedIndex)\"\r\n})\r\n\r\n$btnSetSelectedItemToZ.Add_ButtonPressed({\t\r\n\t$Listbox.SelectedItem = \"Z\"\r\n})\r\n\r\n###$btnSetSelectedItemToD.Add_ButtonPressed({\t\t\r\n###\t$Listbox.SelectedItem = \"D\"\r\n###})\r\n\r\n$btnChangeSelectedItemValueToZ.Add_ButtonPressed({\t\t\t\r\n\t$SelectedItemIndex = $Listbox.Items.IndexOf($Listbox.SelectedItem)\r\n\t$Listbox.Items[$SelectedItemIndex] = \"Z\"\t\r\n})\r\n \r\n$root.Run()\r\n```"},"comment":{"url":"https://api.github.com/repos/LokiMidgard/NSCI/issues/comments/397809697","html_url":"https://github.com/LokiMidgard/NSCI/issues/13#issuecomment-397809697","issue_url":"https://api.github.com/repos/LokiMidgard/NSCI/issues/13","id":397809697,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NzgwOTY5Nw==","user":{"login":"LokiMidgard","id":389101,"node_id":"MDQ6VXNlcjM4OTEwMQ==","avatar_url":"https://avatars3.githubusercontent.com/u/389101?v=4","gravatar_id":"","url":"https://api.github.com/users/LokiMidgard","html_url":"https://github.com/LokiMidgard","followers_url":"https://api.github.com/users/LokiMidgard/followers","following_url":"https://api.github.com/users/LokiMidgard/following{/other_user}","gists_url":"https://api.github.com/users/LokiMidgard/gists{/gist_id}","starred_url":"https://api.github.com/users/LokiMidgard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LokiMidgard/subscriptions","organizations_url":"https://api.github.com/users/LokiMidgard/orgs","repos_url":"https://api.github.com/users/LokiMidgard/repos","events_url":"https://api.github.com/users/LokiMidgard/events{/privacy}","received_events_url":"https://api.github.com/users/LokiMidgard/received_events","type":"User","site_admin":false},"created_at":"2018-06-16T12:41:47Z","updated_at":"2018-06-16T12:41:47Z","author_association":"OWNER","body":"Should now work. the text elemend did calculate with a width of 0 how many lines it needs. which resulted in more lines the longer the text was."}}
{"actor":{"display_login":"LokiMidgard"}}