Search Results

Search found 369 results on 15 pages for 'observablecollection'.

Page 10/15 | < Previous Page | 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Improve WPF Rendering Performance (WrapPanel in ItemsControl)

    - by Wonko the Sane
    Hello All, I have an ItemsSource that appears to have poor performance when adding even a fairly small ObservableCollection to it. The ItemsPanel is a WrapPanel, and the ItemTemplate is essentially a Border containing another Border painted with an ImageBrush. The ItemsControl is wrapped inside a ScrollViewer. After some investigation using WpfPerf, it would appear that most of the "what the heck is it doing?" time is spent on WrapPanel.Measure after creating the collection that is being bound. As I've mentioned, it's a fairly small collection - generally less than 100 items. If nothing else, I'd like to be able to put a "Please Wait" on the screen (during the collection creation portion as well), but I am not sure how to know when the rendering is complete. Any thoughts would be greatly appreciated! Thanks, wTs

    Read the article

  • Binding Listbox ItemsSource to property of ViewModel in DataContext in WPF

    - by joshperry
    I have a simple ViewModel like: public class MainViewModel { public MainViewModel() { // Fill collection from DB here... } public ObservableCollection<Projects> ProjectList { get; set; } } I set the window's DataContext to a new instance of that ViewModel in the constructor: public MainWindow() { this.DataContext = new MainViewModel(); } Then in the Xaml I am attempting to bind the ItemsSource of a ListBox to that ProjectList property. Binding just ItemsSource like so doesn't work: <ListBox ItemsSource="{Binding ProjectList}" ItemTemplate="..." /> But if I first rebase the DataContext this works: <ListBox DataContext="{Binding ProjectList}" ItemsSource="{Binding}" ItemTemplate="..." /> Shouldn't the first method work properly? What am I doing wrong?

    Read the article

  • WPF DataGrid : CanContentScroll property causing odd behavior

    - by Sonic Soul
    i have a solution where i generate a DataGrid (or multiple instances) based on user criteria.. each grid keeps receiving data as it comes in via ObservableCollection the problem i had, was that the scroll acted weird. It was choppy, and scrollbar would resize it self while scrolling. than i found.. CanContentScroll property! It completely fixes the weird scrolling behavior bringing me temporary bliss and happiness. however, it causes 2 unfortunate side effects. whenever i re-create grid instances and bind them to my observable collection, it freezes my entire window for 5 seconds. when my grid grows to a big size, this delay can last for 30 seconds. when i call TradeGrid.ScrollIntoView(TradeGrid.Items(TradeGrid.Items.Count - 1)) to scroll to the bottom, it jumps to bottom and than back to the top. is there another way to achieve smooth scrolling perhaps?

    Read the article

  • WPF ComboBox text inside ListBox

    - by geosteve
    I've got a list of ComboBoxes inside a listbox, like so: <ListBox ItemsSource="{Binding Values}"> <ListBox.ItemTemplate> <DataTemplate> <ComboBox ItemsSource="{...}" IsTextSearchEnabled="True" IsEditable="True"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> The Values for my listbox ItemsSouce is defined in my ViewModel as public ObservableCollection<string> Values { get; set; } How can I get the Text for each one of the ComboBoxes to show the Value for that particular ListBox item? (i.e. if values is {"a", "b", "c"} I want a list of 3 comboboxes showing "a", "b" and "c")

    Read the article

  • Silverlight DataGrid refresh problem

    - by Krimson
    Hi, I have encountered a problem when I refresh the observable collection behind my Silverlight DataGrid (the DataGrid binds to a PagedCollectionView with an ObservableCollection as source). When I clear the observable collection and add the new items to the collection the DataGrid repositions to the top. I want the DataGrid to keep the scroll position. This seems to somewhat happen if I remove the items in the collection one-by-one with the RemoveAt mehtod and the add the new items one-by-one. But why is there this difference between removing all the items at once with the Clear method and removing the items one-by-one with the RemoveAt method? Best Regards, Jesper

    Read the article

  • Databinding a ListBox with SelectionMode = Multiple

    - by David Veeneman
    I have a WPF ListBox that I would like to Enable multiple selection in the ListBox, and Databind the ListBox to my view model. These two requirements appear to be incompatible. My view model has an ObservableCollection<T> property to bind to this ListBox; I set up a binding in XAML from the property to the ListBox.SelectedItems property. When I compiled, I got an error saying that the SelectedItems property was read only and could not be set from XAML. Am I binding to the wrong control property? Is there a way to bind a multiple-selection ListBox in XAML to a view model collection property? Thanks for your help.

    Read the article

  • MVVM Good Design. DataSet or a RowViewModel

    - by LnDCobra
    I have just started learning MVVM and having a dilemna. If I have a a main ViewModel and inside this model I have a number of datasets. Now should I be creating a new ViewModel for each row inside the dataset? Or expose the DataSet itself as a DependencyProperty? For now the dataset has about 20 rows inside it, and the thought of iterating through each row to create a ViewModel binding to each row.... might not be the best option for performance reasons and memory reasons in the future, like when there are 1000+ rows. Should I still go ahead and create a RowViewModel and iterate through the dataset? And have an ObservableCollection of it or just expose the dataset? Any help would be greatly appreciated.

    Read the article

  • WPF listbox : problem with selection

    - by KiTe
    Hello. In my XAML file, I have a ListBox declared like this : <ListBox x:Name="lstDeck" Height="280" ItemsSource="{Binding Path=Deck}" > <ListBox.ItemTemplate> <DataTemplate> <ListBoxItem Content="{Binding}" /> </DataTemplate> </ListBox.ItemTemplate> </ListBox> In my view model, Deck is an ObservableCollection, so that binding directly displays the content of my collection. But when I have several value that hold the same value (for example "10" six times), the selection in the ListBox has a weird behaviour : it select 2-3 elements instead of the only the one on which I clicked. Moreover, when I click to another listBoxItem, it doesn't unfocus the previous selected one. Then it is impossible to see which item is actually selected, and impossible to get the SelectedIndex value. Has someone an idea?

    Read the article

  • WPF -- Event Threading, GUI updating question

    - by LSTayon
    I'm trying to send two events to the main window so that I can show some kind of animation that will let the user know that I'm updating the data. This is an ObservableCollection object so the OnPropertyChanged is immediately picked up by the bindings on the main window. The sleep is only in there so that the user can see the animation. However, the first OnPropetyChanged is never seen. I'm assuming this is because we're in a single thread here and the timer_Tick has to finish before the GUI updates. Any suggetions? In VB6 land we would use a DoEvents or a Form.Refresh. Thanks! private void timer_Tick(object sender, EventArgs e) { Loading = "Before: " + DateTime.Now.ToString(); OnPropertyChanged("Loading"); LoadData(); Thread.Sleep(1000); //Loading = Visibility.Hidden; Loading = "After: " + DateTime.Now.ToString(); OnPropertyChanged("Loading"); }

    Read the article

  • Setting DataContext in a Listbox Declaratively

    - by Oscar
    Hi, I am a newbie in this Silverlight Databinding subject. I am starting to understand how cool is this declaratively way of data binding. To try it out, I have this listbox in my Page.xaml: <ListBox Height="100" Name="lbCategories" Width="236" HorizontalAlignment="Left" Margin="20,0,0,0" SelectionMode="Multiple" ItemsSource="{Binding Categories}" DisplayMemberPath="Name" /> In my Page.xaml.cs I have a public property called Categories of the type ObservableCollection. It works if this following line is present in my CS file: DataContext = this; But I want to avoid any programatically databinding. I would like to set the DataContext to "this" in my ListBox element declarativelly. Is there any way of doing that? Thanks, Oscar

    Read the article

  • MVVM in a canvas with usercontrols

    - by Mauro Destro
    I have a MVVM WPF application that basically wants to be a single line diagram designer for an electrical distribution network. I have a canvas that must contains transformers, circuit breaker, lines and cables. My big problem is the design... How can i start? I think about a DesignerView, DesignerViewModel that contains an ObservableCollection of IDesignerItemViewModel that is my base class for all the element. But in this case I have to use ItemsControl to bind the content of the canvas to my collection but the pros is that I don't have to create usercontrol for each element but i'll solve most of the problems with DataTemplate (i suppose). Each element viewmodel mantain a link to a model persisted in a repository where i mantain my logical tree. Any hint about how to proceed, I have looked at many DiagramCanvas example but all of those use simple items most like simple rectangle...

    Read the article

  • silverlight with WCF(get data through collections)

    - by Piyush
    in my silverlight page I am fetching the data through WCF WCF is returning an BusinessEntityCollection that is the collection of rows SqlParameter[] sqlParameter = new SqlParameter[]{new SqlParameter("@recordType",recordType)}; MenuEntity menuEntity; MenuEntityCollection menuEntityCollection = new MenuEntityCollection(); using (SqlDataReader sqlDataReader = SqlHelper.ExecuteReader(_ConnectionString,CommandType.StoredProcedure, StoredProcedures.GetMenus, sqlParameter)) { if (sqlDataReader.Read()) { menuEntity = new MenuEntity(); DataAccessHelper.GetEntity(sqlDataReader, menuEntity); menuEntityCollection.Add(menuEntity); } } return menuEntityCollection; -- in silverlight page when I am calling WCF there I am getting an error MenuEntity menuList = new MenuEntity(); menuList = e.Result; <-----error line error: Cannot implicitly convert type 'System.Collections.ObjectModel.ObservableCollection' to 'FastTrackSLUI.AdminServiceReference.MenuEntity'

    Read the article

  • Silverlight 4 accessing WCF Data Services: BeginInvoke frustrations.

    - by Gatmando
    Hi, I'm attempting to follow a pattern for performing WCF data service queries using the Silverlight 4 beta. The following is my code: public CodeTables() { CodeCountries = new ObservableCollection<dsRealHomes.CodeCountries>(); dsRealHomes.RealHomesEntities myClient = null; myClient = staticGlobals.RealHomesContext(); object userState = null; myClient.BeginExecute<dsRealHomes.CodeCountries>(new Uri("CodeCountries"), (IAsyncResult asyncResult) => { Dispatcher.BeginInvoke( () => { var test = myClient.EndExecute<dsRealHomes.CodeCountries>asyncResult).ToList(); } ); }, userState); } This is derived from a number of examples I've come across for WCF data services with silverlight. Unfortunately no matter how I try to implement the code i end up with the following error on 'Dispatcher.BeginInvoke': 'An object reference is required for the non-static field, method, or property (System.Windows.Threading.Dispatcher.BeginInvoke(System.Action)' Thanks

    Read the article

  • How do you handle the deletion of your model working with ViewModels and keeping them in sync ?

    - by Lisa
    Hello, these could be my entity relations: 1 Pupil has 1 Chair 1 Pupil has N Documents 1 Pupil has N Marks 1 Pupil has N IncidentReports etc... So with that sample I get 4 IEnumerable from my database put each into an ObservableCollection. Now I have 4 different Views each bound to one of those 4 collections. Lets assume I delete a single PupilViewModel in the AdministrationController which is the only View where I can delete a PupilViewModel. Now I have to inform 3 other Controller and their ObservableCollections about the one deleted PupilViewModel to keep the whole application synchronized... thats stupid somehow. Do you have any good advice on that scenario? AND it gets even worse. If I delete a schoolclass I have to sync the pupils everywhere AND the documents or incidentreports or marks... gush... o_O

    Read the article

  • [WPF] SelectionChanged of a child ListBox

    - by quimbs
    Hi, I have a ListBox bound to an ObservableCollection with an ItemTemplate that contains another ListBox. First of all, I tried to get the last selected item of all the listboxes (either the parent and the inner ones) from my MainWindowViewModel this way: public object SelectedItem { get { return this.selectedItem; } set { this.selectedItem = value; base.NotifyPropertyChanged("SelectedItem"); } } So, for example, in the DataTemplate of the items of the parent ListBox I've got this: <ListBox ItemsSource="{Binding Tails}" SelectedItem="{Binding Path=DataContext.SelectedItem, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/> The problem now, is that when I select an item from the parent ListBox and then an item from a child listbox, I get this: http://i40.tinypic.com/j7bvig.jpg As you can see, two items are selected at the same time. How can I solve that? Thanks in advance.

    Read the article

  • Setting TreeView.DataContext doesn't refresh the tree

    - by dan gibson
    I have a List that I've bound to a TreeView. Setting TreeView.DataContext works - everything displays correctly. I then change the list (add an item to it) and set TreeView.DataContext again (to the same value) but the tree does not refresh with the new items. How do I get the treeview to refresh? This is basically my code: public class xItemCollection : ObservableCollection<xItem> { } public class xItem : INotifyPropertyChanged { xItemCollection _Items; public xItem() { _Items = new xItemCollection(); } public xItemCollection Items {get{return _Items;}} } ... this.RootItem = new xItem(); treeView.DataContext = this; Adding items to the list works until the tree is rendered for the first time. After it is rendered, adding/removing items does not refresh the tree.

    Read the article

  • Binding scattered/overlapping images to a WPF Canvas

    - by bufferz
    I am porting a GDI application over to WPF, where I displayed several dozen images onto Form, then drew polygons, circles, rectangles, etc over the top of these images using GDI Pens and Brushes. I'm starting to get the hang of WPF binding and would like to store all of these images and markup graphics in my ViewModel. My VM contains an ObservableCollection of my custom DrawingEntitys, DrawingEntity contains DependencyProperties for BitmapSource, Height, Width, CanvasTopLeftY, and CanvasTopLeftX, that I update frequently in the collection. I know my binding is working, I just can't figure out how to bind and draw this collection onto a Canvas. I've played around with ItemsControl and ItemsSource to death, too many different ways to list here. I can display the DrawingEntity.Bitmaps onto the canvas but Canvas.Top won't bind to CanvasTopLeftY in the DrawingEntity, everything is overlapped at 0,0. I think I'm missing an obvious strategy. Any ideas?

    Read the article

  • WPF: Bind/Apply Filter on Boolean Property

    - by Julian Lettner
    I want to apply a filter to a ListBox accordingly to the IsSelected property of a CheckBox. At the moment I have something like this. XAML <CheckBox Name="_filterCheckBox" Content="Filter list" Checked="ApplyFilterHandler"/> <ListBox ItemsSource="{Binding SomeItems}" /> CodeBehind public ObservableCollection<string> SomeItems { get; private set; } private void ApplyFilterHandler(object sender, RoutedEventArgs e) { if (_filterCheckBox.IsChecked.Value) CollectionViewSource.GetDefaultView(SomeItems).Filter += MyFilter; else CollectionViewSource.GetDefaultView(SomeItems).Filter -= MyFilter; } private bool MyFilter(object obj) { return ... } It works but this solution feels like the old-fashioned way (Windows Forms). Question: Is it possible to achieve this with Bindings / in XAML? Thanks for your time.

    Read the article

  • WPF ItemsControl - how to know when the items finished loading, so that I can focus the first one?

    - by Tomáš Kafka
    Hi everyone, I have an ItemsControl in my View, that is bound to an ObservableCollection from ViewModel. The collection is filled, and afterwards an event from VM to view is raised (think search results and SearchFinished event). I would like to move keyboard focus to the first item in an ItemsControl, but when I do it in View's code-behind when handling SearchFinished, the items are not yet rendered (the collection is filled already, but wpf's rendering is asynchronous and didn't happen yet), so there is nothing to focus (Focus() needs to have the items' visual tree already constructed). I wanted to do (myItemsControl.ItemContainerGenerator.ContainerFromIndex(0) as UIElement).Focus();, but as the 0th item is not yet loaded, ContainerFromIndex(0) returns null. I tried delaying it with Dispatcher.BeginInvoke... with low priority, but that is dependent on exact timing and usually doesn't work. How can I wait until the first item in ItemsControl is Loaded?

    Read the article

  • WPF: change DataTemples according to Value

    - by Kave
    I have a class called Cell with two properties. One is called Value of type int? And the other is called Candidates of type ObservableCollection during the initialization I am utilizing a DataTemplateSelector to choose between two datatemplates for two different scenarios. If the Value property has a value then template A should be used to present the Cell class. However if the Value property is null Then template B should be used to present the Cell class. While this works perfectly fine during the initialization however during the runtime the templates don't change any more when the value of the Value property actually changes. Is the approach of using DataTemplateSelector the wrong approach to change DataTemplates dynamically? What would you recommend I should do? Many thanks,

    Read the article

  • PropertyChanged doesn't work properly

    - by Karen
    Hello, I have a Silverlight application in which I implemented MVVM pattern. In my application there is a child window on which I have ComboBox. I bound ItemsSource and SelectedItem of my combobox to a property (typeof ObservableCollection) and property of MyType appropriately. MyType is a "MODEL" derived from INotifyPropertyChanged. When my window is loaded I set values to this properties. But my combobox doesn't display selected item. I found that when I set property which is bound to selected item (in ViewModel), the PropertyChanged event is null. Can anyone help me. Thanks.

    Read the article

  • C# WPF: Combobox isn't jumping down the list as I type when I use a multiconvert on it.

    - by michael paul
    Basically, I have a combobox that is built by doing multibinding (multiconverter) for the memberdisplaypath. The problem is if the combobox is selected and I start typing, it doesn't jump down the list. Doesn't it go by what's displayed in the combobox for typing? That is, if the combobox is setup like so: //value/display (please disregard how weird the numbering is...) //ref - the value is built upon an observablecollection of a class. ref / "" ref / "10 - Very much agree." ref / "15 - Somewhat agree." ref / "19 - No weight." ref / "23 - Somwhat disagree." ref / "33 - Very much disagree." If the user presses the "1" key it should jump to "10 - Very much agree." But, instead it just sits there...

    Read the article

  • What causes a WPF ListCollectionView that uses custom sorting to re-sort its items?

    - by Drew Noakes
    Consider this code (type names genericised for the purposes of example): // Bound to ListBox.ItemsSource _items = new ObservableCollection<Item>(); // ...Items are added here ... // Specify custom IComparer for this collection view _itemsView = CollectionViewSource.GetDefaultView(_items) ((ListCollectionView)_itemsView).CustomSort = new ItemComparer(); When I set CustomSort, the collection is sorted as I expect. However I require the data to re-sort itself at runtime in response to the changing of the properties on Item. The Item class derives from INotifyPropertyChanged and I know that the property fires correctly as my data template updates the values on screen, only the sorting logic is not being called. I have also tried raising INotifyPropertyChanged.PropertyChanged passing an empty string, to see if a generic notification would cause the sorting to be initiated. No bananas. EDIT In response to Kent's suggestion I thought I'd point out that sorting the items using this has the same result, namely that the collection sorts once but does not re-sort as the data changes: _itemsView.SortDescriptions.Add( new SortDescription("PropertyName", ListSortDirection.Ascending));

    Read the article

  • Binding command to button in silverlight 4 using mvvm

    - by Archie
    Hello, I have a user control called HomePage.xaml. I'm creating a model instance (using MVVM pattern) in the code behind file in the constructor of page as MainViewModel model = new MainViewModel(); I have a button in HomePage.xaml which I want to bind to the command inside MainViewModel called GetData() and want to populate the data in datagrid. MainViewModel has an ObservableCollection which I would use to bind the data in datagrid. Populating the data in datagrid without binding command works fine. I'm binding the button as: <StackPanel x:Name="stkPanelInput" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center"> <Button x:Name="buttonGetData" Width="70" Content="GetData" Command="{Binding GetData}" Click="buttonGetData_Click"/> </StackPanel> How shall I bind the command using MVVM? Thanks.

    Read the article

  • ItemsControl that loads items one by one asynchronously.

    - by Vinit Sankhe
    Hey Guys, I am creating a custom DataGrid by deriving the traditional tookit based WPF DataGrid. I want a functionality in the grid to load items one by one asynchronously, wherein as soon as ItemsSource is changed i.e. a new collection is Set to the ItemsSource property or the bound collection is Changed dues to items that rae added, moved or removed (wherein the notifications comes to the data grid when the underlying source implements INotifyCollectionChanged such as ObservableCollection). This is because even with virtualising stackpanel underneath the datagrid takes time to load (2-3 seconds delay) to load the data rows when it has several columns and some are template based. With above behavior that delay would "appear" to have reduced giving datagrid a feel that it has the data and is responsive enough to load it. How can I achieve it? Thx Vinit.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15  | Next Page >