|
Hehhehe!
Hey why don't you also participate in the Q & A section? Just curious!
People with high attitude deserve the standing ovation of our highest finger!
My Blog![ ^]
|
|
|
|
|
Thanks - think I get your point, unless you have very big DataGrid or List, VirtualizingStackPanel carries more overhead than a simple Grid/StackPanel.
dev
|
|
|
|
|
|
VirtualizingStackPanel is only used when you are displaying a variable number of items. Like a ListBox or a ListView, etc. You generally don't use it in your application. The differences between the various panels are too numerous to mention, you need to read up on them. The main difference is the various layout techniques and abilities.
|
|
|
|
|
|
Hi,
can any one tell me how to add the values from textbox(UI of text box) into a directive list, which is already containing a data like this...
void DerivedAttributePanel_Loaded(object sender,RoutedEventArgs e)
{
List<Directive> list = new List<Directive>();
list.Add(new Directive { DirectiveName = "Filter1", Description = "Description 1" });
list.Add(new Directive { DirectiveName = "Filter2", Description = "Description 2" });
list.Add(new Directive { DirectiveName = "Filter3", Description = "Description 3" });
lbDirectiveList.ItemsSource = list;
}
class Directive
{
public string DirectiveName { get; set; }
public string Description { get; set; }
}
basically i want to update this directive list from the user data which is enterred in the Textbox from UI of the application, so can u tell me how to do it...
|
|
|
|
|
I would recommend you to use ObservableCollection instead of List because the former can notify you whenever your collection changes.
private ObservableCollection<Directive> list;
void DerivedAttributePanel_Loaded(object sender,RoutedEventArgs e)
{
list = new ObservableCollection<Directive>();
list.Add(new Directive { DirectiveName = "Filter1", Description = "Description 1" });
list.Add(new Directive { DirectiveName = "Filter2", Description = "Description 2" });
list.Add(new Directive { DirectiveName = "Filter3", Description = "Description 3" });
lbDirectiveList.ItemsSource = list;
}
private void AddData_Click(object sender, RoutedEventArgs e)
{
Directive newDirect = new Directive { DiretiveName = txtFilter.Text, Description = txtDesc.Text };
list.Add(newDirect);
}
People with high attitude deserve the standing ovation of our highest finger!
My Blog![ ^]
modified on Wednesday, April 13, 2011 1:41 PM
|
|
|
|
|
I have used the above code, but it is not loading(displaying) the data which i enterred in the textbox control into a listbox lbDirectiveList.
|
|
|
|
|
Are you binding to the ObservableCollection? This would typically look like this:
<ListBox ItemsSource="{Binding lbDirectiveList}" ItemTemplate="{StaticResource myDataTemplate}" />
|
|
|
|
|
No, am binding to a list...
but when am adding the values to list, it is not appearing in that listbox..
|
|
|
|
|
Are you sure that it's an ObservableCollection you are binding to? There's nothing magical about an ObservableCollection, except that for binding purposes it implements the ICollectionChanged interface and raises notifications when things have changed in it.
Check your Visual Studio output window to see if there are any binding errors in there causing it to fail.
|
|
|
|
|
You must be missing the ItemTemplate for the ListBox.
<ListBox Name=" "...>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=DirectiveName}"/>
<TextBlock Text="{Binding Path=Description}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Try now.
People with high attitude deserve the standing ovation of our highest finger!
My Blog![ ^]
|
|
|
|
|
Hello,
I have a listbox bound to a DataView showing rows from a table (ReportingUser) in a typed DataSet. The table has a DataRelation to another table (Reporting). Hence the (typed) row objects have a ReportingRow property that refers to the corresponding row in the related table.
Each row is displayed using text from the Reporting related table:
<ListBox Name="listBoxSelectedReporting" ItemsSource="{Binding User/User_ReportingUser}"
DisplayMemberPath="Row.ReportingRow.ReportingName" />
I would like to sort the listbox by ReportingName as well. I have been struggling with this for two days. None of the solutions I found via Google work. They include:
1/ Use a SortDescription. But that mechanism doesn't seem capable of following property chains, unlike DisplayMemberPath.
2/ Grab the defaultView and set the Sort property. But the mechanism is string-based and gives access to the row's columns only.
3/ Cast the defaultView to a ListCollectionView and set a custom IComparer. But the cast fails.
I also had an idea: use a partial class definition to add a new property, to be used in SortDescriptions:
partial class ReportingUserRow
{
public string ReportingName
{
get
{
return ReportingRow.ReportingName;
}
}
}
Alas when I try to use it in either DisplayMemberPath or SortDescription, I get an exception that the property doesn't exist.
UPDATE: I can use my property in DisplayMemberPath like this: DisplayMemberPath="Row.ReportingName"
Which opens the question: using the debugger I see that my listbox contains a DataView that contains DataRowView objects which in turn contain a reference to a row object (of type ReportingUserRow). How does DataRowView find out what properties are available on a ReportingUserRow ? Why does it find the columns and not my extra property ?
modified on Wednesday, April 13, 2011 6:03 AM
|
|
|
|
|
1) I'm pretty sure that doesn't work... the implementation pretty much reflects on the current type and gets a property named "x". "Row.ReportingRow.ReportingName" is not the name of a valid property.
3) Should work just fine. I do it all over the place. How are you getting the default view? Show code. If the cast is failing, what IS GetDefaultView() returning?
|
|
|
|
|
Relevant lines from Window_Loaded:
dataset = new DNLMHDataSet();
reportingUserAdapter = new ReportingUserTableAdapter();
reportingUserAdapter.Fill(dataset.ReportingUser);
listBoxSelectedReporting.DataContext = dataset;
I run my program and make it break. In the Immediate window:
?System.Windows.Data.CollectionViewSource.GetDefaultView(listBoxSelectedReporting.DataContext)
{System.Windows.Data.BindingListCollectionView}
[System.Windows.Data.BindingListCollectionView]: {System.Windows.Data.BindingListCollectionView}
CanFilter: false
CanGroup: true
CanSort: false
Culture: null
CurrentItem: {System.Data.DataViewManagerListItemTypeDescriptor}
CurrentPosition: 0
Filter: null
GroupDescriptions: {System.Collections.ObjectModel.ObservableCollection<System.ComponentModel.GroupDescription>}
Groups: null
IsCurrentAfterLast: false
IsCurrentBeforeFirst: false
IsEmpty: false
SortDescriptions: {System.ComponentModel.SortDescriptionCollection.EmptySortDescriptionCollection}
SourceCollection: {System.Data.DataViewManager}
Let's try the cast:
?(ListCollectionView)System.Windows.Data.CollectionViewSource.GetDefaultView(listBoxSelectedReporting.DataContext)
Cannot cast 'System.Windows.Data.CollectionViewSource.GetDefaultView(listBoxSelectedReporting.DataContext)' (which has an actual type of 'System.Windows.Data.BindingListCollectionView') to 'System.Windows.Data.ListCollectionView'
When I look at the MS headers I see that both ListCollectionView and BindingListCollectionView derive from CollectionView. They're siblings, hence no cast...
|
|
|
|
|
So, um... didn't you just answer your own question???
In your particular case, you have a BindingListCollectionView, not a ListCollectionView. Simply cast the GetDefaultView() return into a BindingListCollectionView object and use that. GetDefaultView() actually returns an ICollectionView object. So, it is possible to get ANYTHING implementing the ICollectionView interface (like BindingListCollectionView in this case).
BindingListCollectionView implements everything you need. Like Comparer for example 
|
|
|
|
|
SledgeHammer01 wrote: BindingListCollectionView implements everything you need. Like Comparer for example
...but the Comparer property is read-only And it has the SortDescriptions but it's useless for my purpose... 
|
|
|
|
|
Oh right... sorry, yeah, I forgot some of the view classes randomly make useful properties read-only .
Ok, well, then there are a few ways you can proceed.
1) You are getting BindingListCollectionView because you are binding to a source that implements IBindingList. So you can repackage the data in something different like an ObservableCollection<T>, etc.
2) You can try wrap your source in a CollectionViewSource. CollectionViewSource requires the source to implement IEnumerable which should work for you.
#2 is probably easier, but if that doesn't work, you'll have to do #1 . It kind of makes sense that what you are trying to do is not really supported directly.
|
|
|
|
|
I tried yet another approach: sort the rows at the source, using this code:
dataset.ReportingUser.OrderBy(
row =>
{
System.Diagnostics.Trace.WriteLine("*** called ***");
return row.ReportingRow.ReportingName;
});
I tried putting it before and after the call to reportingUserAdapter.Fill(dataset.ReportingUser) but it is never called.
Feeling despaired... 
|
|
|
|
|
I am trying to modify an RC remote controlled car so I can control it wirelessly from a wp7 platform but and I designed a masked textbox for an IP address input, I would like to know how the phone would wirelessly connect to the access point which is a router
|
|
|
|
|
At the moment, you can't. WP7 programming is still at the abstraction stage - in other words, it's been developed to make WP7 programming simple, so a lot of nuts and bolts stuff is hidden from you. This is unlikely to change in the near future.
|
|
|
|
|
OK, so I've worked with Winforms and Webforms for 20 years.
But now I've been thrown into building a Silverlight 4 application from scratch without ANY previous training. So please bear with me if I ask some questions here that seems stupid to people who have worked a lot with Silverlight before.
My first worry is: Do you really have to use WCF/Entity Framework services to access data from a Silverlight app. Can't you use the traditional ADO.Net objects (SqlDataConnection, SqlCommand, SqlDataReader etc) and access the SQL server directly like you can from a Webforms app?
The reason I ask is that my few tests have shown me that compared to a Webapp with ADO.Net data access, WCF and Entity Framework services are painfully slow. And since I know already from the specs that we need the performance to be absolutely optimal, I would prefer to do it the traditional way.
However, when I choose add reference in my Silverlight project and want to add System.Data.SqlClient, it's not there. That makes me wonder if it's not possible to use it.
????
TIA!
Beidh ceol, caint agus craic againn - Seán Bán Breathnach ----- Don't tell my folks I'm a computer programmer - They think I'm a piano player in a cat house... ----- Da mihi sis crustum Etruscum cum omnibus in eo! ----- Everybody is ignorant, only on different subjects - Will Rogers, 1924
|
|
|
|
|
You're mixing things up a bit...
First, remember that a Silverlight application runs on the client side, not the server. The client uses WCF to communicate with a server-side process, and the server can use Entity Framework or ADO.Net to communicate with the database.
WCF = Communication framework, to send messages between the client and server (Or other things)
Entity Framework = A way to map database objects into CLR objects, to simplify data access... Basically a wrapper around ADO.NET.
|
|
|
|
|
Ian Shlasko wrote: You're mixing things up a bit...
I might be - as mentioned, this is a first for me. I thought the silverlight app was rendered from the server as is the case with a normal webapp. If it physically runs on the client, then I can (to a certain point) understand my mixup.
But then again: If I install a winform app on the client machine, then I can access a remote db directly without WCF, as long as I know the correct query string. Why isn't that possible in Silverlight?
Beidh ceol, caint agus craic againn - Seán Bán Breathnach ----- Don't tell my folks I'm a computer programmer - They think I'm a piano player in a cat house... ----- Da mihi sis crustum Etruscum cum omnibus in eo! ----- Everybody is ignorant, only on different subjects - Will Rogers, 1924
|
|
|
|
|
Johnny J. wrote: But then again: If I install a winform app on the client machine, then I can access a remote db directly without WCF, as long as I know the correct query string. Why isn't that possible in Silverlight?
You CAN have a Silverlight app go straight to the database, with the right security permissions and open ports on your network, though you're not really supposed to. Silverlight apps are supposed to access data by communicating with a server application, not by going directly to a database server.
So in short, the standard way to do it is:
Client-side SL App --[WCF]--> Server Application --[ADO/EF]--> Database
But if you cut out the server application and open your database to outside connections, you CAN do:
Client-side SL App --[ADO/EF]--> Database
EDIT: Ok, actually, I'm wrong about being able to do it that way... Silverlight isn't designed to go straight to a database at all...
http://forums.silverlight.net/forums/p/1350/3283.aspx[^]
|
|
|
|