foreach (var property in typeof(MyClassFromEntity).GetProperties())
{
foreach (var attribute in property.GetCustomAttributes(true))
{
if(attribute is DisplayNameAttribute)
{
var displayNameAttribute = attribute as DisplayNameAttribute;
var displayName = displayNameAttribute.Name;
}
else if(attribute is GroupNameAttribute)
{
var groupNameAttribute = attribute as GroupNameAttribute;
var groupName = groupNameAttribute.Name;
}
}
}
class ProfOrg
{
private Union _union;
public ProfOrg(Union union)
{
_union = union;
}
public void AddEvent(UnionEvent unionEvent)
{
_union.Events.Add(unionEvent);
}
}
class Union
{
private ProfOrg _profOrg;
private List<UnionEvent> _events;
public List<UnionEvent> Events { get { return _events; } }
public ProfOrg ProfOrg { get{ return _profOrg; }
public Union()
{
events = new List<UnionEvent>();
profOrg = new ProfOrg(this);
}
}
<ComboBox ItemsSource={Binding Items}>
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding FirstName}"/>
<TextBlock Text="{Binding LastName}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
private static int tick = Environment.TickCount;
public int Id
{
get{return Interlocked.Increment(ref tick);}
}
public interface INotifyCoordinateChanged
{
string Name{get;set;}
double X{get;set;}
double Y{get;set;}
double Z{get;set;}
event Action<INotifyCoordinateChanged> CoordinateChanged;
}
List<INotifyCoordinateChanged> Objects{get;set;}
public class OnlyTextValidationRule : ValidationRule
{
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
{
bool noNumbers = Regex.Matches("^([^0-9]*)$",value.ToString()).Count > 0;
return new ValidationResult(noNumbers, "Value contains numbers");
}
}
<Window.Resources>
<local:OnlyTextValidationRule x:Key="NoNumberValidate"/>
</Window.Resources>
<TextBox Text={Binding Value, ValidationRules={StaticResource NoNumberValidate}}/>
public class PressureViewModel:INotifyPropertyChanged
{
private double _pressure;
public double Pressure
{
get{return _pressure;}
set
{
_pressure = value;
SendPropertyChanged("Pressure");
}
}
protected void SendPropertyChanged(string propertyName)
{
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
}
public class PaskalToBarConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
// метод преобразования паскаль в бар
return PaskalToBar((double)value);
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
//метод преобразования бар в паскаль
return BarToPaskal((double)value);
}
}
xmlns:converters="clr-namespace:ConvertersNamespace"
<Window.Resources>
<converters:PaskalToBarConverter x:Key="PaskalToBar"/>
</Window.Resources>
<TextBox x:Name="PaskalPressure" Text={Binding Pressure}/>
<TextBox x:Name="BarPressure" Text={Binding Pressure, Converter={StaticResource PaskalToBar}}/>
У каждого листа своя структура, и у каждой версии файла структура листа может быть другой.