I’m performing a Drag and Drop between two grids. The row is not removed from the first grid after the drop is completed. Both the grids have the same ObservableCollection. Did anyone notice this behavior?
RJ
<telerik:RadComboBox x:Name="rcbImages" VerticalAlignment="Center" IsEnabled="False" SelectedValue="{Binding Condition}" Visibility="Hidden" telerik:StyleManager.Theme="Office_Blue" Width="150" Grid.Column="5">
<telerik:RadComboBox.SelectionBoxTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="40" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="{Binding Key.Description}" />
<Image Grid.Column="0" Source="{Binding Value}">
</Image>
</Grid>
</DataTemplate>
</telerik:RadComboBox.SelectionBoxTemplate>
<telerik:RadComboBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="40" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="{Binding Description}" />
<Image Grid.Column="0" Source="{Binding Value}" Initialized="Image_Initialized" Loaded="Image_Loaded" ImageFailed="Image_ImageFailed">
</Image>
</Grid>
</DataTemplate>
</telerik:RadComboBox.ItemTemplate>
</telerik:RadComboBox>
BitmapImage bitimage = new BitmapImage();
bitimage.BeginInit();
bitimage.StreamSource =
new System.IO.MemoryStream(images[i].ImageValue);
bitimage.EndInit();
images[i].Image = bitimage;
Dictionary<ImageType, BitmapImage> dicImages = new Dictionary<ImageType, BitmapImage>();
for (int i = 0; i < images.Count; i++)
{
dicImages.Add(images[i], images[i].Image);
}
combo.SelectedValuePath =
"Key.ImageKey";
combo.ItemsSource = dicImages;
combo.IsEnabled =
true;
Any help would be greatly appreciated.
Thanks,
Jonathan
<P><DataTemplate DataType="{x:Type vm:DeviceInventoryListViewModel}" > <BR> <local:DeviceInventoryList/> <BR></DataTemplate> <BR><DataTemplate DataType="{x:Type vm:AccountMaintenanceListViewModel}"> <BR> <local:AccountMaintenanceList /> <BR></DataTemplate></P>My ShellViewModel is as follows:
Public Class ShellViewModel
Inherits ViewModelBase
Private _openviews As ObservableCollection(Of ViewModelBase)
Private _currentview As ViewModelBase
Public ReadOnly Property Views As ObservableCollection(Of ViewModelBase)
Get
If _openviews Is Nothing Then
_openviews = New ObservableCollection(Of ViewModelBase)
AddHandler _openviews.CollectionChanged, AddressOf ViewCollectionChanged
LoadDefaultViews()
End If
Return _openviews
End Get
End Property
Private Sub LoadDefaultViews()
_openviews.Add(New DeviceInventoryListViewModel)
_openviews.Add(New AccountMaintenanceListViewModel)
_currentview = _openviews.Item(0)
End Sub
Public Property SelectedView As ViewModelBase
Get
Return _currentview
End Get
Set(ByVal value As ViewModelBase)
_currentview = value
OnPropertyChanged("SelectedView")
End Set
End Property
End Class
And then my ShellView has its DataContext set to an instance of my ShellViewmodel and the XAML contains the following:
<telerik:RadTabControl Grid.Row="1" ItemsSource="{Binding Views}" SelectedItem="{Binding SelectedView}" /> <UserControl x:Class="MyAppDesktopWPF.TreeviewView" xmlns:Telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" xmlns:csla="clr-namespace:Csla.Data;assembly=Csla" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400" Loaded="UserControl_Loaded" xmlns:my="clr-namespace:MyAppDesktopWPF.ViewModels">
<UserControl.Resources>
<CollectionViewSource x:Key="TreeAreaDS" Source="{Binding Source={StaticResource TrashViewModel}, Path=Model}"></CollectionViewSource>
<HierarchicalDataTemplate x:Key="ToolsDataTemplate"ItemsSource="{Binding Tools}" > <TextBlock Text="{Binding Path=Name}" FontWeight="Bold"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="SegmentsDataTemplate"ItemsSource="{Binding Segments}" ItemTemplate="{StaticResource ToolsDataTemplate}" > <TextBlock Text="{Binding Path=Name}" FontWeight="Bold"/> </HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="SectionsDataTemplate" ItemsSource="{Binding Sections}" ItemTemplate="{StaticResource SegmentsDataTemplate}"> <TextBlock Text="{Binding Path=Name}"FontWeight="Bold"/> </HierarchicalDataTemplate>
</UserControl.Resources>
<Telerik:RadTreeView ItemsSource="{Binding Source={StaticResource TreeAreaDS}}" ItemTemplate="{StaticResource SectionsDataTemplate}"Name="PlanTreeView" Height="250" HorizontalAlignment="Left" Margin="3"VerticalAlignment="Center" Width="150" />public class TrashViewModel : ViewModel<MyAppBO.MyClass> { public TrashViewModel() { Bxf.Shell.Instance.ShowStatus(new Bxf.Status { Text = "Getting Plan", IsBusy = true }); ManageObjectLifetime = true; // cascade model changed events through VM to View Model.PropertyChanged += (o, e) => OnPropertyChanged(e.PropertyName); }
public TrashViewModel(MyClass classInstance) { Bxf.Shell.Instance.ShowStatus(new Bxf.Status { Text = "Getting Plan", IsBusy = true }); ManageObjectLifetime = true; Model = classInstance;
// cascade model changed events through VM to View<br> Model.PropertyChanged += (o, e) => OnPropertyChanged(e.PropertyName); } <CollectionViewSource x:Key="TreeAreaDS"Source="TrashViewModel"></CollectionViewSource><Style TargetType="{x:Type telerik:GridViewFooterCell}"> <Setter Property="HorizontalAlignment" Value="Right"/></Style>