Hi All, I have following class
public abstract class AbsTrinityEvent
{
public event IsSelected OnSelectedEvent;
bool _IsSelected;
ITrinityEvent _objTrinityEvent;
public AbsTrinityEvent(ITrinityEvent objTrinityEvent)
{
_objTrinityEvent = objTrinityEvent;
}
public ITrinityEvent TrinityEventObj
{
set
{
_objTrinityEvent = value;
}
get
{
return _objTrinityEvent;
}
}
public int EventRefID
{
get
{
return _objTrinityEvent.EventRefID;
}
}
public string EventDescription
{
get
{
return _objTrinityEvent.EventDescription;
}
}
public string EventDateTime
{
get
{
return _objTrinityEvent.EventDateTime;
}
}
public string Site
{
get
{
return _objTrinityEvent.Site;
}
}
public int Priority
{
get
{
return _objTrinityEvent.Priority;
}
}
public string DeviceName
{
get
{
return _objTrinityEvent.DeviceName;
}
}
public bool IsAlarm
{
get
{
return _objTrinityEvent.IsAlarm;
}
}
public string OperatorName
{
get
{
return _objTrinityEvent.OperatorName;
}
}
public int SiteID
{
get
{
return _objTrinityEvent.SiteID;
}
}
public int EventSrcInstanceID
{
get
{
return _objTrinityEvent.EventSrcInstanceID;
}
}
public int EventSrcInstanceMasterDeviceID
{
get
{
return _objTrinityEvent.EventSrcInstanceMasterDeviceID;
}
}
public bool IsSelected
{
set
{
_IsSelected = value;
ItemSelectedEventArgs obj = new ItemSelectedEventArgs(_objTrinityEvent);
OnSelectedEvent(this, obj);
}
get
{
return _IsSelected;
}
}
}
public class ItemSelectedEventArgs : EventArgs
{
private ITrinityEvent _objItem;
public ItemSelectedEventArgs(ITrinityEvent objItem)
{
_objItem = objItem;
}
public ITrinityEvent SlectedNode
{
get
{
return _objItem;
}
}
}
public sealed class TrinityEventData : AbsTrinityEvent
{
public TrinityEventData(ITrinityEvent objEvent)
: base(objEvent)
{
}
}
I am binding this to my listview in code behind ( Not in XAML ) using following function
public void SetupColumnsForUnAcklist()
{
//Create Columns for listview
GridView grdView = new GridView();
grdView.Columns.Add(new GridViewColumn() { DisplayMemberBinding = new Binding() { Path = new PropertyPath("EventDescription") }, Header = "Description" });
grdView.Columns.Add(new GridViewColumn() { DisplayMemberBinding = new Binding() { Path = new PropertyPath("EventDateTime") }, Header = "Date:Time" });
grdView.Columns.Add(new GridViewColumn() { DisplayMemberBinding = new Binding() { Path = new PropertyPath("Site") }, Header = "Site" });
grdView.Columns.Add(new GridViewColumn() { DisplayMemberBinding = new Binding() { Path = new PropertyPath("DeviceName") }, Header = "Device" });
grdView.Columns.Add(new GridViewColumn() { DisplayMemberBinding = new Binding() { Path = new PropertyPath("Priority") }, Header = "Priority" });
lstview_Unack.View = grdView;
//Do Binding
if (_alarmUnAckList != null)
{
lstview_Unack.SetBinding(ListView.ItemsSourceProperty, new Binding() { Source = _alarmUnAckList });
lstview_Unack.SetBinding(ListView.IsSelectedProperty, new Binding() { Path = new PropertyPath("IsSelected") });
}
lstview_Unack.ContextMenu = contextMenu;
foreach (GridViewColumn col in grdView.Columns)
{
comboColumnList.Items.Add(col.Header as string);
}
}
My problem is, I want bind ListViewItem "IsSelected" Property to the TrinityEventData's "IsSelected" Property. How I should I do it in code behind.
Please help.
Regards Sandeep