|
/********************************************************************
* FulcrumWeb RAD Framework - Fulcrum of your business *
* Copyright (c) 2002-2009 FulcrumWeb, ALL RIGHTS RESERVED *
* *
* THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED *
* FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE *
* COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE *
* AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT *
* AND PERMISSION FROM FULCRUMWEB. CONSULT THE END USER LICENSE *
* AGREEMENT FOR INFORMATION ON ADDITIONAL RESTRICTIONS. *
********************************************************************/
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace Framework.Silverlight.Client
{
/// <summary>
/// Visual control for section list.
/// </summary>
public partial class CxSectionsList
{
private readonly ObservableCollection<CxSectionDescriptor> m_Sections = new ObservableCollection<CxSectionDescriptor>();
public event EventHandler SelectedSectionChanged;
//----------------------------------------------------------------------------
/// <summary>
/// Default .ctor
/// </summary>
public CxSectionsList()
{
InitializeComponent();
sectionsList.ItemsSource = m_Sections;
}
//----------------------------------------------------------------------------
/// <summary>
/// Adds section to list.
/// </summary>
/// <param name="section"></param>
public void AddSection(CxSectionDescriptor section)
{
if(!m_Sections.Contains(section))
{
m_Sections.Add(section);
}
}
//----------------------------------------------------------------------------
/// <summary>
/// Removes all section from control.
/// </summary>
public void ClearSections()
{
m_Sections.Clear();
}
//----------------------------------------------------------------------------
/// <summary>
/// Handles ListBox.SelectionChanged event.
/// </summary>
private void sectionsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if(SelectedSectionChanged != null)
{
SelectedSectionChanged(this, EventArgs.Empty);
}
}
//----------------------------------------------------------------------------
/// <summary>
/// Gets the selected section.
/// </summary>
public CxSectionDescriptor SelectedSection
{
get { return (CxSectionDescriptor)sectionsList.SelectedItem; }
}
//----------------------------------------------------------------------------
/// <summary>
/// Finds and does as selected a section with specified Id.
/// </summary>
/// <param name="sectionId">Id of section to select.</param>
public void SelectSectionById(string sectionId)
{
foreach (CxSectionDescriptor section in sectionsList.Items)
{
if(section.Id.Equals(sectionId))
{
sectionsList.SelectedItem = section;
return;
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.