|
Hi Jeremy,
One way could be to have a property in the ViewModel like this:
private int _selectedIndex = -1;
public int SelectedIndex
{
get { return _selectedIndex; }
set
{
if (value != _selectedIndex)
{
_selectedIndex = value;
NotifyPropertyChanged("SelectedIndex");
}
}
}
It's set to -1 initially so the XAML doesn't throw an error when there's no collection to bind to.
Bind it to the list box:
<ListBox ItemsSource="{Binding Employees}" SelectedIndex="{Binding SelectedIndex}" />
Then, in the completed event (when the service returns from the asynchronous call with the data) you can set it to whatever you want.
void svcClient_GetDataCompleted(object sender, EmployeeSvc.GetDataCompletedEventArgs e)
{
Employees = e.Result;
SelectedIndex = 1;
}
Not particularly elegant, but it seems to work.
Cheers.
|
|
|
|
|
My data has many columns but a few rows. I need to “rotate” the display with the DataGrid. I wish the DataGrid could display rows as columns, and columns as rows. Is it possible?
|
|
|
|
|
I don't think the datagrid does any transposing at the moment.
This[^] blog post shows a way of transposing your data instead.
Hope that helps.
|
|
|
|
|
hi friends,
i am using a datagrid for my application, i have a combos box in which i am populating data frm a class ie i am using cellEditingTemplate <combobox itemsource="{Binding" theclassname.listused}="" selecteditem="ListUseddataId"> etc i am not able to populate data in the combobox.. how can i debug a combodox data if it is used as data template?
Thanks in Advance...
Regards
Samir
|
|
|
|
|
VCsamir wrote: i am not able to populate data in the combobox
How are you trying to populate the combobox?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I m working on a windows project . i m new in WPF. so my question is can we use wpf controls and graphics in my existing windows project....tell me sum link for tutorial to if this is possible
|
|
|
|
|
Do you mean that you want to host WPF controls inside a WinForms application? Why not write the whole application in WPF?
If you do mean hosting inside WinForms, you might want to follow the tutorial here[^].
"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 dont want to change the whole application. I want to apply WPF graphics on some of my pages.
IS its possible???????????
|
|
|
|
|
You can probably embed a WPF window here and there, but I think it's a dumb idea. You'd do better to start with WPF, embed your winforms controls as needed, and do the rest with WPF.
Christian Graus
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.
|
|
|
|
|
anuj1784 wrote: IS its possible???????????
Did you even look at the link I included in my post?
"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
|
|
|
|
|
ohh sorry i thought u not understand wat i m tring to say
|
|
|
|
|
Hi,
I am developing a wpf application, with which I need to develop a user control,
but for now I am trying to achieve that functinality on one of my WPF forms first.
All I needed is picture(thumbnail size) list on the left side(vertically) of the form, and should able to manually scroll though the list
I am using Grid -> button(UP) in first row, button(DOWN) in third row ->
scroll viewer in middle row -> listbox(within the scroll viewer) -> individul images in the listbox
My main goal is to animate the imagelist vertically on clicking up or down button accordingly,
Now I almost got this simple functionality by setting scrollviewer's contentverticaloffset property,
but it's not smooth, it does not animate but just move up and down. Is there anyway I can animate this list smoothly?
I hope the problem makes sense, I am kind of new to WPF.
Thanks
|
|
|
|
|
grvdarji wrote: listbox(within the scroll viewer)
A listbox by default already has a scrollviewer wrapping its items presenter.
Do you just need to scroll through the images or do you also
need to be able to select images?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for the reply, Mark
Actually, the moment I clik on any image in listbox, the big image of the same, should show up in right hand side big image control.
So in order to answer your que.
No it is not just scrolling but I should be able to select and use that image-ID as well.(So it has to be a button at the top and bottom of listbox for manual scrolling since I don't want default scrolling, also I should not click(pick) and move image for scrolling.)
Just FYI: the thumbnail and big image are diff. image and coming from MS access 2007 DB.
Sorry for less info. in first time.
|
|
|
|
|
There's lots of ways to accomplish this.
If you want to use a ListBox, you could
1) remove your scrollviewer to use the one in the listbox
2) re-template the listbox as show in the sample code here:
ItemsControl.ItemsPanel Property[^]
setting the scrollviewers scrollbarvisibility properties to Hidden
3) At runtime, find the listbox's scrollviewer so you can manipulate it
programmatically, as shown here: Access ScrollViewer from within a style[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for letting me understand the tree structure of the controls in WPF.
the posts you have directed to, are surely helpful.
I tried the same tree structure, and code.
(Correct me if I am wrong but, the code I have seen also had scrollviewer inside the border control, I also tried removing scrollviewer(to use listbox's default) as you said earlier but it stopped scrolling, then I put it back as the code sujjested and as per my previous working Markups)
Now, the main thing is that, after trying it, All I could get is step by step scrolling which I was getting before too.
I intend to get smooth scrolling, just like you hold scroll bar and move little up/down, but on click of my up/Down buttons.
thanks for the reply, it cleared my other doubts though.
|
|
|
|
|
Hi
I recently did some digging on the internet and I found a way to use the Vista Aero theme in Windows XP. One can simply add the following line of code to the App.xaml file:
<ResourceDictionary Source="/PresentationFramework.Aero, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml"/>
Now my question is, how can I specify this line of code when I already have other styles etc. specified in the App.xaml file? It gives me an error saying "Cannot add element to property 'Resources', because the property can have only one child element if it uses an explicit collection tag". It works when I remove everything else from App.xaml though.
|
|
|
|
|
You need to use a merged dictionary. Here's one from one I'm working on right now:
<Application
x:Class="Goldlight.SampleApplication.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Themes/BureauBlue/Theme.xaml"/>
<ResourceDictionary Source="Goldlight.Resources.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
"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
|
|
|
|
|
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="...aero etc etc..."/>
<ResourceDictionary Source="...your dictionary..."/>
<ResourceDictionary Source="...and many more..."/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
EDIT: Ah well, Pete beat me to it.
|
|
|
|
|
Good job though.
"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've create some web services that return, for example, a List<myclass> to the client and it is been working fine.
But now I'm trying to pass a List<myclass> as parameter from the client to a function in a web service but it does not compile. The compiler only accepts it if the List is of type object as in List<object>
Is it possible to acomplish what I'm trying to do or it only works if is List<object>?
Is there any other way to send the list to the server (Maybe FTP or something else)?
Any link to a good explanation on how to work with List<object> ?
Thanks
|
|
|
|
|
The error actually happens in the app side and not in the web. private List<person>
myList = new List<person>(); // Same as declared in the web side
// Populate myList with some items .......
private void btn_Click(object sender, RoutedEventArgs e)
{
ServiceReference1.Service1Client proxy = new SilverlightApplication2.ServiceReference1.Service1Client();
proxy.SetPersonsCompleted += new EventHandler<system.componentmodel.asynccompletedeventargs>(proxy_SetPersonsCompleted);
proxy.SetPersonsAsync(myList);} // This line always underlined in blue by the compiler
void proxy_SetPersonsCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
throw new NotImplementedException();
}
public class Person
{ public string name;
public int age;
}
Here is the error:
Error 1 The best overloaded method match for 'SilverlightApplication2.ServiceReference1.Service1Client.SetPersonsAsync(System.Collections.ObjectModel.ObservableCollection<silverlightapplication2.servicereference1.person>)' has some invalid arguments E:\SilverlightApplication2\Views\Home.xaml.cs 35 13 SilverlightApplication2
Error 2 Argument '1': cannot convert from 'System.Collections.Generic.List<silverlightapplication2.person>' to 'System.Collections.Generic.List<silverlightapplication2.servicereference1.person>' E:\SilverlightApplication2\Views\Home.xaml.cs 35 35 SilverlightApplication2
|
|
|
|
|
hi..
There is one solution to it.. in your webservice create a List<Objects> populate it and pass it back to your silverlight solution,
now while reading the data from the object list to should have the class which will hold this data, use IEnumerater to go thru your list
and get the data
IEnumerator enumerator = e.Result.(Yourlist).GetEnumerator();
for (int i = 0; i < e.Result.(Yourlist).Count; i++)
Person = new person();
person.name= (yourList).toString();
person.Age= (int)(yourList);
Hope this helps u... :=)
|
|
|
|
|
I want to send the list to the web service not the other way around. For this there is an easier solution: Just send the list as a return value of the function call to the web service.
In your example what is enumerator used for?
|
|
|
|
|
CBenac wrote: Error 1 The best overloaded method match for 'SilverlightApplication2.ServiceReference1.Service1Client.SetPersonsAsync(System.Collections.ObjectModel.ObservableCollection)' has some invalid arguments E:\SilverlightApplication2\Views\Home.xaml.cs 35 13 SilverlightApplication2
Shouldn't you be using an ObservableCollection<> instead of a List<> on the
client side, since that's what the generated code is expecting?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|