Posted 02 Sep 2010 Link to this post
public
partial
class
Window1 : Window
{
List<Image> lista;
private
const
String Extension =
"(*.jpg)|*.jpg|(*.png)|*.png"
;
Window1()
InitializeComponent();
lista =
new
List<Image>();
Microsoft.Win32.OpenFileDialog dialog ;
}
void
button1_Click(
object
sender, RoutedEventArgs e)
lista.Clear();
dialog =
Microsoft.Win32.OpenFileDialog { RestoreDirectory =
true
, Filter = Extension, Multiselect =
};
if
(dialog.ShowDialog() ==
)
foreach
(
string
Name
in
dialog.FileNames)
Image Im =
Image()
Im.Source =
BitmapImage(
Uri(fName, UriKind.Relative));
lista.Add(Im);
this
.radCarousel1.ItemsSource = lista;
Posted 03 Sep 2010 Link to this post
You just have to use ObservableCollection in stead of List so that the carousel receives notifications when new items are added to your source collection.
I understand but I have had problems, I captured the notification and will insert the list at the carousel ItemSource but does not display images ... public
RadObservableCollection<Image> list;
String ExtensionFilter =
list =
RadObservableCollection<Image>();
list.CollectionChanged +=
System.Collections.Specialized.NotifyCollectionChangedEventHandler(list_CollectionChanged);
list_CollectionChanged(
sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
.radCarousel1.ItemsSource = (Image)sender;
Microsoft.Win32.OpenFileDialog dialog =
, Filter = ExtensionFilter, Multiselect =
fileName
Image();
Uri(fileName, UriKind.Relative));
list.Add(Im);
else
Posted 06 Sep 2010 Link to this post
There is no need to handle CollectionChange and modify the ItemsSource of the carousel when a new item is added to the source collection. You just need to assign ItemsSource once and the control will take care of the rest.
.radCarousel1.ItemsSource = list
// no need to handle CollectionChanged
//list.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(list_CollectionChanged);