WPF ListView SelectedValue not being set -
i've looked @ few solutions nothing has worked yet me.
i'm using mvvm project , have listview can't set selecteditem property.
if (simplified) xaml.
<listview name="uxpackagegroups" itemssource="{binding path=packagegroups, updatesourcetrigger=propertychanged, mode=twoway}" borderthickness="0" borderbrush="#ff0000e8" scrollviewer.cancontentscroll="true" selecteditem="{binding path=packagegroupselecteditem, mode=twoway}" > <listview.itemtemplate> <datatemplate> <label content="{binding name}" height="20" margin="0" padding="0"/> </datatemplate> </listview.itemtemplate>
and bind packagegroups in viewmodel
public packagegroup packagegroupselecteditem {get; set; } public observablecollection<packagegroup> packagegroups {get; set; } private void loadui() { packagegroups = factory.loadallpackagegroups()) // if try hard-code pre-selected item here doesn't work. // 34 valid id , see valid object when stepping through code packagegroupselecteditem = packagegroup.loadbyid(db, 34); }
anything glaring in code?
thanks.
one possible problem you're not implementing inotifypropertychanged in packagegroupselecteditem property.
Comments
Post a Comment