ValueErrorTraceback (most recent call last) <ipython-input-33-eb3d96398060> in <module>()
19 return arraynd.tolist();
20
---> 21 X_valid = normalizeImages(X_valid)
22 #X_train = normalizeImages(X_train)
23 #X_test = normalizeImages(X_test)
<ipython-input-33-eb3d96398060> in normalizeImages(data)
16 for x in range(0, len(dflat)):
17 dflat[x] = (dflat[x] - mindflat)/(maxdflat - mindflat)* 255
---> 18 arraynd = np.reshape(dflat, (x, y, z, w))
19 return arraynd.tolist();
20
C:\ProgramData\Miniconda3\envs\carnd-term1\lib\site-packages\numpy\core\fromnumeric.py in reshape(a, newshape, order)
222 except AttributeError:
223 return _wrapit(a, 'reshape', newshape, order=order)
--> 224 return reshape(newshape, order=order)
225
226
ValueError: total size of new array must be unchanged
我的视图模型中的<ScrollViewer VerticalScrollBarVisibility="Auto">
<ListBox x:Name="RootListView" ItemsSource="{Binding Ratings}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
.... Some TextBoxes with Labels are here to fill the grid .....
<Button Grid.Row="4" Grid.Column="1" Content="Delete"
Command="{Binding ElementName=RootListView, Path=DataContext.DeleteRatingCommand}"
CommandParameter="{Binding ElementName=RootListView, Path=SelectedItem}">
</Button>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
位于:
Ratings
public ObservableCollection<RatingModel> Ratings;
是DeleteRatingCommand
对象。
此视图中显示了一整套评级(包含信息的网格),每个都有一个删除按钮。当按下相应评级的按钮时,我想将评级对象发送到具有ICommand
属性的视图模型。虽然调用了绑定方法,但是没有通过SelectedItem参数传递任何内容,特别是SelectedItem
值。在这种情况下,如何正确使用null
向视图模型发送有关要删除哪个评级的信息?还有其他可能性吗?我不确定这种方法是否正确。
答案 0 :(得分:1)
我假设点击按钮并没有实际设置SelectedItem属性。
尝试将绑定更改为行上下文数据。
CommandParameter="{Binding Path=.}"