|
Hi,
I have a datagrid(using WPF) and miltiple row selection is allowed. How to get multiple selected items in MVVM pattern?
It is easy to get this in code behind file? But in MVVM pattern codebehind file doesn't contains the much code.
Many thanks.
|
|
|
|
|
There are two parts to this answer. The first part is that you should use a Command to set an IsSelected property on each item in your collection. The second part compensates for the fact you can't bind to a command on the Selected event. To get round this you need to use an EventToCommand Blend Behaviour. Laurent Bugnion has a fine sample in MVVM Light.
|
|
|
|
|
thanks..Can I have that link? I couldn't get it.
|
|
|
|
|
|
I have a table MyTable (comId, groupId, versionId) that is bound to a grid using code.
The default connection generated by domain services works fine
return this.ObjectContext.MyTable;
but I modified the return statement to get one column only
return this.ObjectContext.MyTable.Include("groupId");
This statement compiles correct but returns an error
unhandle error
Manage Runtime
System.ServiceMode.DomainService.Client.DomainOperation Exception
Any help is greatly appreciated
|
|
|
|
|
You may want to post this in the LINQ forum instead rather than randomly choosing one.
|
|
|
|
|
|
As this is related to an article, you should ask on the forum for that article. It's extremely unlikely that the author will happen to wander by this forum and pick up your question.
|
|
|
|
|
I have a partial class to extend my entity framework edmx, it looks like this (in brief)"
public partial class Property
{
private string _displayAddress;
public string DisplayAddress
{
get
{
string address = number.ToString();
if (!String.IsNullOrEmpty(direction))
address += " " + direction;
address += " " + street;
if (suffixId != null)
address += " " + StreetSuffix.name;
if (!String.IsNullOrEmpty(unit))
address += " " + unit;
return address;
}
set { _displayAddress = value; }
}
}
The kicker is that the StreetSuffix is a separate table that is joined to the property table by virtue of suffixId.
The data service class has this: return this.ObjectContext.Properties.Include("StreetSuffix"); .
The metadata class has this:
[Include]
public StreetSuffix StreetSuffix { get; set; }
So what is amiss that is throwing a null error when it tries to process the StreetSuffix.name?
Cheers, --EA
|
|
|
|
|
Ahem. Wrong forum. Try the Linq forum instead.
|
|
|
|
|
I overlooked that forum for some reason, probably cosmic radiation on my brain. Thank you for your patient response.
Cheers, --EA
|
|
|
|
|
No problem, but if you got hit by cosmic radiation, does this mean you've developed cool superpowers?
|
|
|
|
|
Only if male pattern baldness and steady memory loss are considered super powers.
|
|
|
|
|
Hi can anyone tell me how to convert this array class object into normal class object, because it is not showing any method like listbox.move or listbox.remove in a listbox associated with this class object//
public partial class Directive : DependencyObject
{
public static readonly DependencyProperty DirectiveIDProperty = DependencyProperty.Register("DirectiveID", typeof(string),
typeof(Directive));
public static readonly DependencyProperty DirectiveNameProperty = DependencyProperty.Register("DirectiveName", typeof(string),
typeof(Directive));
public static readonly DependencyProperty DirectiveDescriptionProperty = DependencyProperty.Register("DirectiveDescription", typeof(string),
typeof(Directive));
public static readonly DependencyProperty PriorityProperty = DependencyProperty.Register("Priority", typeof(string),
typeof(Directive));
public static readonly DependencyProperty DefaultProperty = DependencyProperty.Register("Default", typeof(string),
typeof(Directive));
public static readonly DependencyProperty SetValueTypeProperty = DependencyProperty.Register("SetValueType", typeof(SetValueType),
typeof(Directive));
public static readonly DependencyProperty ConditionProperty = DependencyProperty.Register("Condition", typeof(Condition[]),
typeof(Directive));
public static readonly DependencyProperty GroupProperty = DependencyProperty.Register("Group", typeof(Group[]),
typeof(Directive));
}
because i was using listdata.move and listdata.remove method with normal class object, where listdata is a itemsource name..
here am not finding any method like this, so can u tell me how can i convert this classarray into normal class type..
|
|
|
|
|
I ve no idea what you are talking about. This is a DependencyObject, not an array. What array are you talking about?
|
|
|
|
|
sorry,
My mistake,
Previously i was able to delete the data from listbox Itemsource, which is getting the data from the object of this class..
Now the class structure has been changed, now the itemsource not contaiin a method like remove, move..
it is taking the value into array associated with this class, so can u tell me how can i delete the object values from this class which it contain..
|
|
|
|
|
The class that contains the collection should use an ObservableCollection to contain this type.
|
|
|
|
|
Hi,
Are there any existing written wpf complete sample projects I can download?
Thanks
|
|
|
|
|
Yep, all over the Internet.
|
|
|
|
|
|
something like 101 wpf sample projects.
I searched google but there is nothing similar.
thanks
|
|
|
|
|
|
|
Hello,
I have two listboxes arranged side by side in a Grid control.
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="40" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<ListBox Grid.Column="0" Name="supply" HorizontalAlignment="Stretch" />
<!-- buttons -->
<ListBox Grid.Column="2" Name="select" HorizontalAlignment="Stretch" />
</Grid>
I want both listboxes to have the same width, regardless of the (text) content of the listboxes.
Initially, the left listbox contains a list of strings. The right listbox is empty. If the maximum width of the items in the left listbox is smaller than (roughly) half of the size allocated to the entire grid, everything is ok. Otherwise, the left listbox occupies whatever width is needed to display the widest visible item, and the other list gets the rest.
I suppose that the grid "asks" each listbox what width it wants, and they in turn ask their items. I'd like to stop the process before the width of the items gets involved, IOW both listboxes should report minimal width, then the grid would have plenty of space on its hands, which it would split evenly between the two listboxes.
How can I achieve that ?
I've seen suggestions on the web, involving either SharedSizeGroup or disabling the listbox' horizontal scrollbar and setting HorizontalContentAlignment to "Stretch". They don't seem to work...I also tried binding the left listbox' MaximalWidth the the right listbox' Width, to no avail.
|
|
|
|
|
The code you posted should do exactly what you want.
When you use star-sizing, the grid does NOT resize columns based on child control sizes... First it sets the size of fixed columns (Like your "40"), then it figures out the size of "Auto" columns by asking the controls in those columns what they need, then it splits up the remainder into the star-sized columns.
My suggestions would be:
1) Make sure the grid itself isn't the piece resizing... If it's inside, say, a ScrollViewer, then it'll enlarge itself to (2 x the widest listbox) + 40... It might be the grid itself being cut off on the right, not the second listbox
2) If your actual code is more complex than this (And I suspect it is), try commenting out a piece at a time until you see the behavior you're expecting.
|
|
|
|