And the journey is complete. This is a clueless post. You can't export a datagrid to Excel. You would export the DATA to Excel, and you'd do that the same way if you were using WPF or not. Ergo, this is not a WPF question and it's one easily answered with a google search.
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
This doesn't work though because I've got to change the cell container's Horizontal alignment.
Also, when using a ListView.ItemContainerStyle, is it possible to trigger off the column by a name or index? As an example, how would one make the background of a column red from the ItemContainerStyle?
Although, this works if the TextBlock's width is specified, I really want to right align to the ListView's grid column and allow the TextBlock's width to expand or contract with the column.
By specfiying a width to the TextBlock, when the column is expanded beyond the width of the TextBlock, the text though aligned to the right of the TextBlock is not aligned to the right of the column.
I believe that one needs to modify the parent's panel's content alignment; though, how do I manipulate that style. Can I use a trigger within a Control template for the ListBoxItem? If so, how do I switch on the column number so that only specified columns are right aligned?
If the textblock has Height and Width set to "Auto" it should resize according to the parent, and setting the TextAlignment should be independent of the textblock size. However, I have not messed with the listview control much myself. I prefer the DataGrid provided in the WPF Toolkit. Sorry if this does not help.
Never used the WPF toolkit, but thanks for the pointer. The DataGrid appears to have a number of features that will make it a much more attractive solution. Thanks for the comment. That's just what I needed.
I don't know of a simpler way. My guess is that you'd need to
scale/translate the polyline points separately and create a new PolyLine
from those points if you want to prevent the strokethickness from getting
hello everybody Iwant to create video chat application in wpf and that should be peer to peer. I developed an application by looking article at codeproject wpf/wcf peer to peer chat application . But thats simply broadcasting my video to other peers and when the other peer starts sharing his cam then the both stream mixes up and I get output on my screen in which the streams of both the users mixes up and I we see pictures of both the users alternatively. and moreover it has performanve issuses also. video quality is perfect but speed is very very slow. So plz guide me how to do this???????????
Thanks for replying but can u suggest me someway. how to do this.In my peer to peer application there is only one function that I have declared in the interface and is automatically called for all the nodes in the mesh. and that fnction is accepting "stream " of the person who started sharing his video to others,and this fnctio is called for each node, If now some other user starts his video sharing then it will again call the same function that was already running for this user and the rest of users and at thuis stage both the streams get mixed and I havnt found a way to separate these streams and call the function that is accepting stream.
You would have a boolean property on the data, let's call it Selected. Then you bind your checkbox to the property, and your code simply updates the data - leaving the binding engine to ensure that the checkbox is updated as a result. Don't try to do something like this in the UI, use the data to control it.
"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.
Apologies in advance, I suspect there may be an obvious answer to this, but I have searched these forums and google and not really been able to determine the solution.
This is for a WPF application, but I think it is a more general programming question.
We have an ObservableCollection(of T), where we need do do some validation of the member object, T. One of the rules is that a property of T (say name) cannot already exist in the collection.
Our validation class is instantiated from the xaml, so I don't know of any way to pass in the reference to the ObservableCollection. However, this is needed to be able to step through the collection, to see if name has already been used, and report an error (if needed).
One solution I can see is that the class T could have a property which is an ObservableCollection of T, and then you pass the parent collection into the member object. I think this will solve the issues, but something says to me this would be bad practise... Can anyone clarify whether this will cause errors or should be avoided? Can anyone suggest an alternative?
More specifically, say we define Person
Public Class Person
Public Sub New(ByVal Name As String, ByVal People As ObservableCollection(Of Person))
Public Property Name() As String
Public Property People() As ObservableCollection(Of Person)
Then elsewhere make a collection of Person
Dim MemberList As New ObservableCollection(Of Person)
MemberList.Add(New Person("John", MemberList))
MemberList.Add(New Person("Fred", MemberList))
MemberList.Add(New Person("Jane", MemberList))
MemberList.Add(New Person("Andrew", MemberList))
Then we can bind say a WPF DataGrid to MemberList, and use validation to check our rule, to check that the Person name has not already been used in the ObservableCollection(of Person) - ie MemberList. The approach here will work, but I am concerned that there might be underlying problems - some circular reference or something (or else just not good practise).
Thank you for your reply. I have read the article you refer to ("The Observable Dictionary Sample" - correct?), however I am not clear on how this might solve the problem.
I need to explain a bit more about the scenario. We have a WPF DataGrid bound to our ObservableCollection - this works really well. I am now trying to handle validation as a user makes changes. Where the valiadtion can be based solely on the content of the member object (ie the data in the row, e.g. ensure an age is between 5 and 50) - no problem, use the ValidationRule approach as is well documented. What I am having trouble with is the scenario where a value must be checked against all others in the ObservableCollection - I don't know of any way to make the ValidationRule class know about the parent collection.
So I think this problem will exist, whether we are using ObservableCollection or ObservableDictionary. Please correct me if I have misunderstood your post.
Maybe I am missing something, on how we can pass in the parent collection, to the ValidationRule instance (ie NameRule) that is doing the validation.
There could be several ways to solve this, outside of the DataGrid, but I am trying to find the best method which utilises the WPF way of doing validation.
BTW, I have reviewed the excellent article "WPF DataGrid Practical Examples" [^], and this addresses data validation. However the example provided is based on a DataTable as itemssource (in which case you can refer back to the DataTable), and it seems there should also be a way to use ObservableCollection as the itemssource.
Any further suggestions would be appreciated.
Last Visit: 31-Dec-99 18:00 Last Update: 22-Sep-23 9:46