Search Results

Search found 12126 results on 486 pages for 'property hiding'.

Page 86/486 | < Previous Page | 82 83 84 85 86 87 88 89 90 91 92 93  | Next Page >

  • How to keep a local value from being set when a binding fails (so inherited values will propagate)

    - by redoced
    Consider the following scenario: I want to bind the TextElement.FontWeight property to an xml attribute. The xml looks somewhat like this and has arbitrary depth. <text font-weight="bold"> bold text here <inlinetext>more bold text</inlinetext> even more bold text </text> I use hierarchical templating to display the text, no problem there, but having a Setter in the template style like: <Setter Property="TextElement.FontWeight" Value="{Binding XPath=@font-weight}"/> sets the fontweight correctly on the first level, but overwrites the second level with null (as the binding can't find the xpath) which reverts to Fontweight normal. I tried all sorts of things here but nothing quite seems to work. e.g. i used a converter to return UnsetValue, which didn't work. I'm currently trying with: <Setter Property="custom:AttributeInserter.Wrapper" Value="{custom:AttributeInserter Property=TextElement.FontWeight, Binding={Binding XPath=@font-weight}}"/> Codebehind: public static class AttributeInserter { public static AttributeInserterExtension GetWrapper(DependencyObject obj) { return (AttributeInserterExtension)obj.GetValue(WrapperProperty); } public static void SetWrapper(DependencyObject obj, AttributeInserterExtension value) { obj.SetValue(WrapperProperty, value); } // Using a DependencyProperty as the backing store for Wrapper. This enables animation, styling, binding, etc... public static readonly DependencyProperty WrapperProperty = DependencyProperty.RegisterAttached("Wrapper", typeof(AttributeInserterExtension), typeof(AttributeInserter), new UIPropertyMetadata(pcc)); static void pcc(DependencyObject o,DependencyPropertyChangedEventArgs e) { var n=e.NewValue as AttributeInserterExtension; var c = o as FrameworkElement; if (n == null || c==null || n.Property==null || n.Binding==null) return; var bex = c.SetBinding(n.Property, n.Binding); bex.UpdateTarget(); if (bex.Status == BindingStatus.UpdateTargetError) c.ClearValue(n.Property); } } public class AttributeInserterExtension : MarkupExtension { public override object ProvideValue(IServiceProvider serviceProvider) { return this; } public DependencyProperty Property { get; set; } public Binding Binding { get; set; } } which kinda works, but can't track changes of the property Any ideas? Any links? thx for the help

    Read the article

  • Is there a cleaner way to Bind property to owner's DataContext?

    - by Dan Bryant
    I have some code that looks like this: <Expander Header="{Binding SelectedSlot.Name}" Visibility="{Binding ShowGroupSlot, Converter={StaticResource BooleanToVisibility}}"> <Controls:GroupPrototypeSlotControl Slot="{Binding DataContext.SelectedSlot, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Expander}}}" /> </Expander> This works, but the ugliness of the Slot Binding bothers me. This is required because the GroupPrototypeSlotControl has a GroupPrototypeViewModel as its DataContext. If I simply use {Binding SelectedSlot}, it attempts to resolve it on the 'child' ViewModel, which fails. I get around this by explicitly looking at the DataContext of my parent control. Is there a cleaner way to do this type of binding?

    Read the article

  • How to access the CGColor property of UIColor in CGContextSetFillColorWithColor?

    - by Azeworai
    CGContextSetFillColorWithColor(g, [UIColor greyColor].CGColor); I'm trying to follow O'Reilly's iPhone Game Development book on page 73 Chapter 3 but I'm running into a compile error that states error: request for member 'CGColor' in something not a structure or union According to the book's errata page this is an unconfirmed errata in the book. I'm hoping that someone could help me replace that line of code to something that works. The example project can be downloaded from sourceforge at this link.

    Read the article

  • MovieClip property - what is the url it goes when I click on it.

    - by cosmorocket
    I have bought a flash template in an online store. There are different buttons on it and some of them link to existing local html files from the pack - index-1.html, index-2.html etc. There are also some buttons that don't go anywhere right now but they are intended to be linked to some urls too. They react with animation on mouse rollover and I suppose they should go to some url if I set it somewhere on click. But there is no documentation about that in the pack. I searched through the Flash source file and all html pages files for something like "index", "geturl", also looked through them manually to realize how it could be made but with no luck. So, my question - is that possible that way or another to make that MovieClip button link to some my page, for example, "contacts.html". Thanks.

    Read the article

  • How to select the first property with unknown name from JSON and how to select first item from array

    - by Oscar Godson
    I actually have two questions, both are probably simple, but for some odd reason I cant figure it out... I've worked with JSON 100s of times before too! but here is the JSON in question: {"69256":{"streaminfo":{"stream_ID":"1025","sourceowner_ID":"2","sourceowner_avatar":"http:\/\/content.nozzlmedia.com\/images\/sourceowner_avatar2.jpg","sourceownertype_ID":"1","stream_name":"Twitter","streamtype":"Social media","appsarray":[]},"item":{"headline":"Charboy","main_image":"http:\/\/content.nozzlmedia.com\/images\/author_avatar173212.jpg","summary":"ate a tomato and avocado for dinner...","nozzl_captured":"2010-05-12 23:02:12","geoarray":[{"state":"OR","county":"Multnomah","city":"Portland","neighborhood":"Downtown","zip":"97205","street":"462 SW 11th Ave","latitude":"45.5219","longitude":"-122.682"}],"full_content":"ate a tomato and avocado for dinner tonight. such tasty foods. just enjoyable.","body_text":"ate a tomato and avocado for dinner tonight. such tasty foods. just enjoyable.","author_name":"Charboy","author_avatar":"http:\/\/content.nozzlmedia.com\/images\/author_avatar173212.jpg","fulltext_url":"http:\/\/twitter.com\/charboy\/statuses\/13889868936","leftovers":{"twitter_id":"tag:search.twitter.com,2005:13889868936","date":"2010-05-13T02:59:59Z","location":"iPhone: 45.521866,-122.682262"},"wordarray":{"0":"ate","1":"tomato","2":"avocado","3":"dinner","4":"tonight","5":"tasty","6":"foods","7":"just","8":"enjoyable","9":"Charboy","11":"Twitter","13":"state:OR","14":"county:Multnomah, OR","15":"city:Portland, OR","16":"neighborhood:Downtown","17":"zip:97205"}}}} Question 1: How do I loop through each item (69256) when the number is random? e.g. item 1 is 123, item2 is 646? Like, for example, a normal JSON feed would have something like: {'item':{'blah':'lorem'},'item':{'blah':'ipsum'}} the JS would be like console.log(item.blah) to return lorem then ipsum in a loop How do I do it when i dont know the first item of the object? Question 2: How do I select items from the geoarray object? I tried: json.test.item.geoarray.latitude and json.test.item.geoarray['latitude']

    Read the article

  • Why can't I *override* and *new* a Property (C#) at the same time?

    - by Tim Lovell-Smith
    According to this question it seems like you can do this for Methods. What I want to know is why it doesn't work when I try it with properties. public class Foo { public virtual object Value { get; set; } } public class Foo<T> : Foo { public override object Value { get { return base.Value; } set { base.Value = (T)value; //inject type-checking on sets } } public new T Value { get { return (T)base.Value; } set { base.Value = value; } } } Error message from C# 4.0 RC1 Error 1 The type 'ClassLibrary1.Foo' already contains a definition for 'Value' ClassLibrary1\Class1.cs 31 22 ClassLibrary1

    Read the article

  • AJAX call + JQuery Dialog Title changing dynamically

    - by Panther24
    I have an AJAX call which loads an Dialog page, now depending upon the content of the data returned on the AJAX call, I want to change the title of the Window, how do I do that. Here is the snippet of code: var divid = "brHistoryForm"; var url = "getRestoreFiles.action?profileName="+profileName; // Create xmlHttp var xmlHttp = AJAX(); // The code... xmlHttp.onreadystatechange=function(){ if(xmlHttp.readyState==4){ document.getElementById(divid).innerHTML=xmlHttp.responseText; } } xmlHttp.open("GET",url,true); xmlHttp.send(null); $('#brHistoryForm').dialog('open'); jQuery('#brHistoryForm').focus(); document.getElementById('pageTitle').innerHTML = "<h2>"+profileName+" - B&R History</h2>" Here 'pageTitle' is a div. When I run the above piece of code, it opens a dialog window, the action is redirected to a jsp page which is loaded inside the div. It works fine, but the title does not get set :(. I've tried to do the setting of the title in the redirected jsp page, it doesn't work either. Here is the code of that JSP page: <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>B&R History</title> </head> <body> <table style="width: 100%"> <tr> <td style="width: 40%"> <div id="pageTitle"> <h2>B&R History</h2> </div> </td> </tr> </table> <table id="diskTable" cellpadding="0" cellspacing="0" border="1" class="display"> <thead> <tr> <th>Select</th><th>Operation</th> <th>Source</th><th>Destination</th> <th>Status</th><th>Start Time</th><th>End Time</th> </tr> </thead> <tfoot></tfoot> <tbody> <s:iterator value="restoreFileList"> <tr> <td> <s:if test="%{status.equals('Finished')}"> <input onClick="loadRestoreForm('<s:property value="name"/>', '<s:property value="to_path"/>', '<s:property value="status"/>')" type="radio" name='chk' id="chk" value="<s:property value='id'/>,<s:property value="status"/>" > </s:if> <s:else> <input type="radio" name='chk' id="chk" value="<s:property value='id'/>,<s:property value="status"/>" disabled> </s:else> </td> <td> <s:if test="%{br_type == 0}"> Backup </s:if> <s:else> Restore </s:else> </td> <td><s:property value="from_path"/></td> <td><s:property value="to_path"/></td> <td><s:property value="status"/></td> <td><s:property value="start_time"/></td> <td><s:property value="end_time"/></td> </tr> </s:iterator> </tbody> </table> </body> </html> Any help would be appreciated.

    Read the article

  • Filter a list of objects using a property that is another list. Usign linq.

    - by Luís Custódio
    I've a nice situation, I think at beginning this a usual query but I'm having some problem trying to solve this, the situation is: I've a list of "Houses", and each house have a list of "Windows". And I want to filter for a catalog only the Houses witch have a Blue windows, so my extension method of House is something like: public static List<House> FilterByWindow (this IEnumerable<House> houses, Window blueOne){ houses.Select(p=>p.Windows.Where(q=>q.Color == blueOne.Color)); return houses.ToList(); } Is this correct or I'm losing something? Some better suggestion?

    Read the article

  • Weirdest PHP error

    - by yes123
    I found in my error log this [12-Nov-2011 19:22:26] PHP Warning: Attempt to assign property of non-object in on line 1768776801 [12-Nov-2011 19:22:31] PHP Warning: Attempt to assign property of non-object in on line 1768776801 [12-Nov-2011 19:22:39] PHP Warning: Attempt to assign property of non-object in on line 1768776801 [12-Nov-2011 19:22:40] PHP Warning: Attempt to assign property of non-object in on line 1768776801 [12-Nov-2011 19:22:46] PHP Warning: Attempt to assign property of non-object in on line 1768776801 [12-Nov-2011 19:22:51] PHP Warning: Attempt to assign property of non-object in on line 1768776801 Of course I don't have any script with 1 bn lines. PHP Version 5.3.3-7 Apache 2 The other weird thing is that I have a set_error_handler( 'myHandler' ); To write in the error log other inforamtion too, but with this error it seems PHP just ignores my error_handler =/ I don't have any code that can generate this errore before my call to set_error_handler

    Read the article

  • Set property with reflection after Fluent Nhibernates automapping has occured?

    - by Marcus
    I have an abstract baseclass with a collection of details IList that is automapped with fnh. After it has been populated with the correct values i would like to set some properties with reflection on the my class that inherits the abstract baseclass. I have tried to accomplish this in the constructor of my abstract baseclass but obviously my Details collection is empty when the occurs so my question is, what is the recommended way of doing this?

    Read the article

  • WPF - How do I use the UserControl with a dependency property and view model?

    - by user320849
    Hello, My goal is to have a user select a year and a month. Translate the selection into a date and have the user control send the date back to my view model. That part works for me....However, I cannot get the ViewModel's initial date to set those drop downs. public static readonly DependencyProperty Date = DependencyProperty.Register("ReturnDate", typeof(DateTime), typeof(DatePicker), new FrameworkPropertyMetadata{BindsTwoWayByDefault = true,}); public DateTime ReturnDate { get { return Convert.ToDateTime(GetValue(Date)); } set { SetDropDowns(value); SetValue(Date, value); } } The SetDropDowns(value) just sets the selected items on the combo boxes, however, the program never makes it to that method. On the view I am using: <cc1:DatePicker ReturnDate="{Binding Path=StartDate, Mode=TwoWay}" IsStart="True" /> If this has been answered, then my bad. I looked around and didn't see anything that worked for me. Thus, when the program loads how do I get the value from the view model to a method in order to set the combo boxes? Thanks, -Scott

    Read the article

  • What is the easiest way to get the property value from a passed lambda expression in an extension me

    - by Andrew Siemer
    I am writing a dirty little extension method for HtmlHelper so that I can say something like HtmlHelper.WysiwygFor(lambda) and display the CKEditor. I have this working currently but it seems a bit more cumbersome than I would prefer. I am hoping that there is a more straight forward way of doing this. Here is what I have so far. public static MvcHtmlString WysiwygFor<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression) { return MvcHtmlString.Create(string.Concat("<textarea class=\"ckeditor\" cols=\"80\" id=\"", expression.MemberName(), "\" name=\"editor1\" rows=\"10\">", GetValue(helper, expression), "</textarea>")); } private static string GetValue<TModel, TProperty>(HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression) { MemberExpression body = (MemberExpression)expression.Body; string propertyName = body.Member.Name; TModel model = helper.ViewData.Model; string value = typeof(TModel).GetProperty(propertyName).GetValue(model, null).ToString(); return value; } private static string MemberName<T, V>(this Expression<Func<T, V>> expression) { var memberExpression = expression.Body as MemberExpression; if (memberExpression == null) throw new InvalidOperationException("Expression must be a member expression"); return memberExpression.Member.Name; } Thanks!

    Read the article

  • SPNavigationNode.IsVisible property not working in sharepoint as expected.

    - by Manish
    I want to hide a quick launch node in a sharepoint site, but it's not working as expected. :( My code is as under: using (SPSite spSiteTest = new SPSite(serverUrl)) { using (SPWeb mySite = spSiteTest.OpenWeb()) { SPNavigationNodeCollection quickLaunchNodes = mySite.Navigation.QuickLaunch; SPNavigationNode navQuickNode = new SPNavigationNode("Title", "www.stackoverflow.com", true); foreach (SPNavigationNode node in quickLaunchNodes) { if (node.Title == navQuickNode.Title) { node.Url = navQuickNode.Url; node.IsVisible = isVisible; node.Update(); //mySite.Update(); return; } } quickLaunchNodes.AddAsFirst(navQuickNode); } } Am I missing something or is it a bug?

    Read the article

  • How can I access and change elements in this private readonly property?

    - by CrimsonX
    I'm trying to figure out how I am able to successfully change a "readonly" array. I have this: namespace ConsoleApplication1 { class Program { static void Main(string[] args) { MyClass myClass = new MyClass(); myClass.Time[5] = 5; // How is this legal? } } public class MyClass { private readonly uint[] time; public IList<uint> Time { get { return time; } } public MyClass() { time = new uint[7]; } } } As I Note above, I would expect that Time[5] would be illegal due to the fact that public IList Time does not have a setter. Additionally, how can I create an array in the constructor which is read-only and unchangeable outside of this class?

    Read the article

  • Can we manipulate (subtract) the value of a property while template bidning?

    - by Subhen
    Hi, I am currently defining few grids as following: <Grid.RowDefinitions> <RowDefinition Height="{TemplateBinding Height-Height/5}"/> <RowDefinition Height="{TemplateBinding Height/15}"/> <RowDefinition Height="{TemplateBinding Height/20}"/> <RowDefinition Height="{TemplateBinding Height/6}"/> </Grid.RowDefinitions> While the division works fine , the subtraction isn't yielding the output. Ialso tried like following: <RowDefinition Height="{TemplateBinding Height-(Height/5)}"/> Still no result. Any suggestions plz. Thanks, Subhen ** Update ** Now In My XAML I tried implementing the IvalueConverter like : <RowDefinition Height="{TemplateBinding Height, Converter={StaticResource heightConverter}}"/> Added the reference as <local:medieElementHeight x:Key="heightConverter"/> In side generic.cs I have coded as following: public class medieElementHeight : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { //customVideoControl objVdeoCntrl=new customVideoControl(); double custoMediaElementHeight = (double)value;//objVdeoCntrl.customMediaPlayer.Height; double mediaElementHeight = custoMediaElementHeight - (custoMediaElementHeight / 5); return mediaElementHeight; } #region IValueConverter Members object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } #endregion } But getting the exception Unknown Element Height in the element RowDefination.

    Read the article

  • I can't use Spring filters in servlet-context XML

    - by gotch4
    For some reason both Eclipse and Spring can't find the filter tag (there is even a red mark)... What's wrong? <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"></bean> <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost/jacciseweb" /> <property name="username" value="root" /> <property name="password" value="siussi" /> </bean> <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="myDataSource" /> <property name="annotatedClasses"> <list> <value>it.jsoftware.jacciseweb.beans.Utente </value> <value>it.jsoftware.jacciseweb.beans.Ordine </value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql"> true </prop> <prop key="hibernate.hbm2ddl.auto"> update </prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop> </props> </property> </bean> <filter> <filter-name>hibernateFilter</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> <init-param> <param-name>singleSession</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>sessionFactoryBeanName</param-name> <param-value>mySessionFactory</param-value> </init-param> </filter> <!-- <aop:config> --> <!-- <aop:pointcut id="productServiceMethods" --> <!-- expression="execution(* product.ProductService.*(..))" /> --> <!-- <aop:advisor advice-ref="txAdvice" pointcut-ref="productServiceMethods" /> --> <!-- </aop:config> --> <bean id="acciseHibernateDao" class="it.jsoftware.jacciseweb.model.JAcciseWebManagementDaoHibernate"> <property name="sessionFactory" ref="mySessionFactory" /> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="mySessionFactory" /> </bean> <tx:annotation-driven /> <bean id="acciseService" class="it.jsoftware.jacciseweb.model.JAcciseWebManagementServiceImpl"> <property name="dao" ref="acciseHibernateDao" /> </bean> <context:component-scan base-package="it.jsoftware.jacciseweb.controllers"></context:component-scan> <mvc:annotation-driven /> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" p:synchronizeOnSession="true" /> <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" /> <mvc:resources mapping="/resources/**" location="/resources/" /> <!-- non serve, è annotato --> <!-- <bean name="/accise" class="it.jsoftware.jacciseweb.controllers.MainController"> </bean> --> </beans> in particular it says "filter" is invalid content

    Read the article

  • Is this possible: JPA/Hibernate query with list property in result ?

    - by Kdeveloper
    In hibernate I want to run this JPQL / HQL query: select new org.test.userDTO( u.id, u.name, u.securityRoles) FROM User u WHERE u.name = :name userDTO class: public class UserDTO { private Integer id; private String name; private List<SecurityRole> securityRoles; public UserDTO(Integer id, String name, List<SecurityRole> securityRoles) { this.id = id; this.name = name; this.securityRoles = securityRoles; } ...getters and setters... } User Entity: @Entity public class User { @id private Integer id; private String name; @ManyToMany @JoinTable(name = "user_has_role", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = {@JoinColumn(name = "security_role_id") } ) private List<SecurityRole> securityRoles; ...getters and setters... } But when Hibernate 3.5 (JPA 2) starts I get this error: org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [org.test.UserDTO] [SELECT NEW org.test.UserDTO (u.id, u.name, u.securityRoles) FROM nl.test.User u WHERE u.name = :name ] Is a select that includes a list as a result not possible? Should I just create 2 seperate queries?

    Read the article

  • IE7 is messing up the z-index property with my subnav (although I've already fixed that!)

    - by JAG2007
    OK, so I had this issue with my jQuery subnav in IE7 where it was scrolling down behind the main content after the header. Did a fair bit of research and found a great fix involving simply applying a z-index value to the header, and one to the main content. All was well. Or so I thought. Turns out IE7 is still messing up the subnav z-index within the header itself. The subnav still drops down behind the tagline, which is also part of the header. Particularly when you hit the subnav on the "Help Now" tab. (again, IE7 only) http://betawww.helpcurenow.org I've applied z-index values to both the subnav and the tagline, but that did not resolve the issue as did adding z-index values for the header and maincontent divs. Any tips? Did I specify my z-index improperly with the subnav? (should I have applied to the parent element?)

    Read the article

  • An Inaccessible JavaScript Object property - Why is Firebug showing this?

    - by Matty
    So, I'm attempting to access the content of an object and for the life of me can't figure out why I can't. I'm starting to believe that the object doesn't have the properties that Firebug indicates that it does. More likely than that I'm just not using the right syntax to access them. Give the following function: function(userData) { console.log(userData); // statement 1 console.log(userData.t_nodecontent); // statement 2 } Which generates the following FireBug output for statement 1 and unknown for statement 2. Is there something obvious that I'm overlooking in the way I'm attempting to reference the value of t_nodecontent? I'm at a loss :(

    Read the article

  • How to copy value from class X to class Y with the same property name in c#?

    - by Samnang
    Suppose I have two classes: public class Student { public int Id {get; set;} public string Name {get; set;} public IList<Course> Courses{ get; set;} } public class StudentDTO { public int Id {get; set;} public string Name {get; set;} public IList<CourseDTO> Courses{ get; set;} } I would like to copy value from Student class to StudentDTO class: var student = new Student(); StudentDTO studentDTO = student; How can I do that by reflection or other solution?

    Read the article

  • Handle property change event listeners (lots of them) more elegantly (dictionary?)

    - by no9
    hELLO ! Here i have a simple class example with three fields of type class B and some other stuff. As you can see im listening on every child object change. Since i could need alot of properties of type class B i wonder if there is a way of shrinking the code. Creating a listener + a method for each seems like i will have ALOT of code. How would i fix this ... using a dictionary or something similar? I have been told that IoC could fix this, but im not sure where to start. public class A : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public int _id; public int Id { get { return _id; } set { if (_id == value) { return; } _id = value; OnPropertyChanged("Id"); } } public string _name; public string Name { get { return _name; } set { if (_name == value) { return; } _name = value; OnPropertyChanged("Name"); } } public B _firstB; public B FirstB { get { return _firstB; } set { if (_firstB == value) { return; } if (_firstB != null) { FirstB.PropertyChanged -= firstObjectB_Listener; } _firstB = value; if (_firstB != null) FirstB.PropertyChanged += new PropertyChangedEventHandler(firstObjectB_Listener); OnPropertyChanged("FirstB"); } } public B _secondB; public B SecondB { get { return _secondB; } set { if (_secondB == value) { return; } if (_secondB != null) { FirstB.PropertyChanged -= secondObjectB_Listener; } _secondB = value; if (_secondB != null) SecondB.PropertyChanged += new PropertyChangedEventHandler(secondObjectB_Listener); OnPropertyChanged("FirstB"); } } public B _thirdB; public B ThirdB { get { return _thirdB; } set { if (_thirdB == value) { return; } if (_thirdB != null) { ThirdB.PropertyChanged -= thirdObjectB_Listener; } _thirdB = value; if (_thirdB != null) ThirdB.PropertyChanged += new PropertyChangedEventHandler(thirdObjectB_Listener); OnPropertyChanged("ThirdB"); } } protected void OnPropertyChanged(string name) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(name)); } } void firstObjectB_Listener(object sender, PropertyChangedEventArgs e) { Console.WriteLine("Object A has found a change of " + e.PropertyName + " on first object B"); } void secondObjectB_Listener(object sender, PropertyChangedEventArgs e) { Console.WriteLine("Object A has found a change of " + e.PropertyName + " on second object B"); } void thirdObjectB_Listener(object sender, PropertyChangedEventArgs e) { Console.WriteLine("Object A has found a change of " + e.PropertyName + " on third object B"); } }

    Read the article

< Previous Page | 82 83 84 85 86 87 88 89 90 91 92 93  | Next Page >