|
Hi,
I have:
Class Persn with name and age props
class Manager with List<person> and event for any change occurs (name changed, person added to list etc.)
on the xaml.cs I have ObservableCollection with get to that list from manager. a listVier is bind to that observable
my problem is how to make the ui to refresh when that event of change is raised.
How can I implement that Observable and control the CollectionChanged?
thanks.
|
|
|
|
|
If u r using ObservableCollection & binded properly to the UI, then it will automatically refresh the UI thread as ObservableCollection automatically triggers INotifyPropertyChanged events.
So, no need to bother about it. Let me know, if you are facing any issue regarding the same...
(Please vote it as answer, if it helps you resolving the issue)
Regards,
- Kunal Chowdhury ( My Blog)
|
|
|
|
|
It sounds like you've got your ObservableCollection in the wrong place. You need to change the List in Manager into an ObservableCollection , so that add and delete events are raised appropriately. Basically, you've wrapped the List up in something that will never see the changes without you explicitly raising a notification, which seems to be a little bit pointless.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I have load a large set of data from SQL Server into a three level tree. It is taking long time to populate the tree.
Is there a way (e.g. lazy loading) to load only few records first and then load the rest of the records so that the tree area doe not remain empty for a long time.
|
|
|
|
|
The normal way to do this is to load all the items at the level you are at, and then add a dummy item to the level below. Then, when you expand your treeview you check to see if the first node below is a dummy node - if so, you remove it and attempt to retrieve data from the database that's a child of the expanding item.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Have you tried using TreeView from Silverlight Toolkit? We can probably provide more helps if you are using Silverlight Toolkit.
Thanks.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
Microsoft MVP (Silverlight), WPF/Silverlight Insiders
|
|
|
|
|
Oh how I wish Silverlight 3 supported virtualization on hierarchical items.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi Thanks for reply. Yes we tried the Silverlight tree, but results are not encouraging. We are only loading few hundred records and most of them are at first noode. It is still taking un-acceptable amount of time.
Regards
Rajeev
|
|
|
|
|
I have a silverlight application,that communicating and getting data through socket communication.At each Receive callback i want to get data and update in the GUI at the moment itself.In this case sending and receiving data asynchronously,but the delegate for GUI updation in action only after all receive callbacks.How can i execute GUI updations sequentially with each callback?
|
|
|
|
|
You can call another service after completing of first call.
For example:
service.Call1Completed += (sender, e) => {
//Update the UI.
service.Call2Completed += (srd,e1) => {
//Update the UI.
};
service.Call2Async();
};
service.Call1Async();
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
Microsoft MVP (Silverlight), WPF/Silverlight Insiders
|
|
|
|
|
My scenario is like this.
SocketReceiveCallback(object sender, SocketAsyncEventArgs e )
{
// read data from e.Buffer.
if ( dataReceived == TotalDataSize ) // checks of the complete reception of one image
{
// update the GUI using the received data.
System.Diagnostics.Debug.WriteLine( “ received image “ );
Dispatcher.BeginInvoke(new DisplayImageDelgate(DislayImageData), imageData); // imageData is a class containing the received data
}
Else
{
// call socket.receiveAsync() to get next set of data.
}
}
private void DisplayImageData (MyImageData data)
{
if (data.ImageStream != null)
{
BitmapImage bmp = new BitmapImage();
bmp.SetSource(new MemoryStream(data.ImageStream));
myReceivedImageCtrl.Source = bmp; //GUI update should happen at this point.
System.Diagnostics.Debug.WriteLine( “ Draw image “ );
}
}
Please note that my application, there is continues async requests to server ( corresponding to user action ) and server responds with a stream of image data( eg:- 100 images. The application needs to update the GUI immediately after each image is received ( even while the server streams the data). In the above case although the SocketReceiveCallback is getting the data continuously from server, the GUI update happens only after all the data receive is completed( which can take a long time ).
It seems that although the DisplayImage function is invoked using BeginInvoke, the system actually executes the display function at a later stage, causing ‘jumping’ image displays
The debug trace obtained was:-
received image
received image
received image
received image
Draw image
Draw image
Draw image
Instead of the needed
received image
Draw image
received image
Draw image
received image
Draw image
What could be done?
Thanks and Regards
JS
|
|
|
|
|
You can create one List and add the image data on completed event. and call the draw before receiving all data.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
Microsoft MVP (Silverlight), WPF/Silverlight Insiders
|
|
|
|
|
Dear all,
I've looked around to find an elegant solution to my problem, but not with a log of success...
I would like to prevent a control (custom label, custom button,...) from being rendered (drawn, painted.. ?) based on a condition (actually, a database linked security check)
but not by using the visibility or opacity properties as I would like to keep these properties freely usable by the users of the control in design mode.
I tried to override OnRender, passing a null drawingContext etc. but it doesn't work.
Does anyone have an idea how to do this ?
Thanks all!
|
|
|
|
|
You could always create an empty style for the control if necessary.
Apply a DataTrigger to apply this style based on your condition.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Yes I investigated this, but how can I reset the style to the default one after ?
The process is quite like this:
public MyLabel()
{
SecurityHandler.Instance.SecurityChanged += new SecurityChangedEventHandler(Instance_SecurityChanged);
}
void Instance_SecurityChanged(object sender, string newUsername, int newSecurityLevel)
{
this.securityVisibilityCheck(); // Should change the style here so
}
Thanks for your quick reply!
|
|
|
|
|
When the condition triggering your data trigger is removed, the default style is automatically reapplied. That't the beauty of triggers - you don't have to write a lot of code to reset things when the condition is no longer true.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Indeed
But unfortunately I do not have a simple trigger to decide, and if I have to handle converters, I prefer to make everything in code.
|
|
|
|
|
So simple...
Just set object.Style = null;
Thanks all!
|
|
|
|
|
I'am trying to develop an asp.net website using silverlight but i've tried to install silverlight but it says i need pre requisites please point me to the correct direction
|
|
|
|
|
All that you need to download is linked to from this page[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You need to have .NET 3.5 service pack 1 and Visual Studio 2008 service pack 1 before installing Silverlight Tool for Visual Studio.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
Microsoft MVP (Silverlight), WPF/Silverlight Insiders
|
|
|
|
|
Hi,
I am working on a silverlight application. In this I need to place usercontrols on a canvas in the Page.xaml page dynamically at run time. Later I need to set the data values for the datagrid on these user controls from the Page.xaml itself. I want to set different data for different user controls.
How can i differentiate these user controls from one another and set differnt data to their datagrid from Page.xaml itself.
please reply me if u have any idea to solve this.
Thanks in advance
|
|
|
|
|
There are a couple of ways to do this; it just depends on whether or not you are using pure databinding and MVVM. If you are using MVVM and pure databinding, then there's very little that you need to do because the View/ViewModel integration will take care of the hard work for you. If you aren't, then you can assign a name to each control when you assign it using the x:Name property, e.g. x:Name="myUserControl1" (this is if you add it into the XAML). If you add it using code behind, you just assign the name to the Name property.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Either you are instantiating the objects yourself, and can take them with x:Name and have your own reference, or you are using them in a template in the DataGrid. If you are using them in a template, you can hook into the <coded>Loaded event and do something with them. For example, you might do this:
<DataGrid>...<u:MyControl Loaded="MyControl_Loaded".../>...</DataGrid>
In the MyControl_Loaded you can then take the event arguments and do something with the control, either processing, passing it into a controller, etc.
|
|
|
|
|
I have a pretty basic question to which I want a solution.
I have a bunch of controls on a WPF form. Some controls are within a Grid. I want these controls to stay centered within the grid when maximizing and resizing the window, but as soon as I maximize my window the controls get thrown out of position. I know this probably has someting to do with the Margin property of the controls. Can someone just please tell me how to set the margin or any other property so that the controls stay where I want them too
Thanks in advance
|
|
|
|