This is just a nice simple demo using toggle buttons to display an accordion style menu.Expanding Menu
Please let me know if this helps you.
Simple programming samples for WPF and C#.
This is just a nice simple demo using toggle buttons to display an accordion style menu.
Having a nice loading panel with a progress bar showing that some work is in progress is a very cool feature to any application.<ctr:LoadingPanel x:Name="loadingPanel"
IsLoading="{Binding PanelLoading}"
Message="{Binding PanelMainMessage}"
SubMessage="{Binding PanelSubMessage}"
ClosePanelCommand="{Binding PanelCloseCommand}" />
I started using .Net Reactive (Rx) extensions for work recently. // Method OnSearchTextChanged is called .5s after Text Box text changed
Observable.FromEvent<TextChangedEventArgs>(textbox, "TextChanged")
.Throttle(TimeSpan.FromSeconds(.5))
.ObserveOnDispatcher()
.Subscribe(OnSearchTextChanged);
I wrote a WPF numeric text box control that can support currency, integer and numeric values.
I was asked to write a prototype for a project that I am currently working on.public class Football
{
[PriorityLevel(1)]
public League League { get; set; }
[PriorityLevel(2)]
public string Team { get; set; }
}
public class PriorityLevelAttribute : Attribute, EnumHelper.IAttribute<int>
{
private readonly int _value;
public PriorityLevelAttribute(int value)
{
_value = value;
}
public int Value
{
get { return _value; }
}
}
/// <summary>
/// Returns the attribute value for a given Enum value.
/// </summary>
public static TR GetAttributeValue<T, TR>(this Enum value)
{
var attributeValue = default(TR);
if (value != null)
{
var fi = value.GetType().GetField(value.ToString());
if (fi != null)
{
var attributes = fi.GetCustomAttributes(typeof(T), false) as T[];
if (attributes != null && attributes.Length > 0)
{
var attribute = attributes[0] as IAttribute<TR>;
if (attribute != null)
{
attributeValue = attribute.Value;
}
}
}
}
return attributeValue;
}
public enum League
{
[DisplayDescription("Argentine Primera Division")]
PrimeraDivision = 1,
[DisplayDescription("English Premier League")]
PremierLeague = 2,
[DisplayDescription("Spanish La Liga")]
LaLiga = 3
}
public class DisplayDescriptionAttribute : Attribute, EnumHelper.IAttribute<string>
{
private readonly string _value;
public DisplayDescriptionAttribute(string value)
{
_value = value;
}
public string Value
{
get { return _value; }
}
}
/// <summary>
/// This is the implementation.
/// </summary>
var displayValue = league.GetAttributeValue<DisplayDescriptionAttribute, string>();

var xmlFile =
new XElement("Movies",
from m in movies
select new XElement("Movie",
new XElement("Title", m.Title),
new XElement("Director", m.Director),
new XElement("ReleaseDate", m.ReleaseDate),
new XElement("Casts",
from c in m.Casts
select new XElement("Cast",
new XElement("Name", c.Name),
new XElement("Dob", c.Dob),
new XElement("Roles",
from r in c.Roles
select new XElement("Role",
new XElement("MovieName", r.Movie),
new XElement("RoleName", r.RoleName)))))));
var movies =
from m in xmlFile.Descendants("Movie")
select new Movie
{
Title = (string)m.Element("Title"),
Director = (string)m.Element("Director"),
ReleaseDate = (DateTime)m.Element("ReleaseDate"),
Casts = (from c in m.Elements("Casts").Descendants("Cast")
select new Cast
{
Name = (string)c.Element("Name"),
Dob = (DateTime)c.Element("Dob"),
Roles = (from r in c.Elements("Roles").Descendants("Role")
select new Role
{
Movie = (string)r.Element("MovieName"),
RoleName = (string)r.Element("RoleName")
}).ToList()
}).ToList()
};
public static class CollectionExtensions
{
public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> ienum)
{
ObservableCollection<T> oc = new ObservableCollection<T>();
foreach (T i in ienum)
{
oc.Add(i);
}
return oc;
}
}