setter

How to set custom property as XAML value?

I have this library with custom Color properties. I wanna be able to use these properties in XAML like this: <Style TargetType="{x:Type eg:MyWindow}"> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="CustomClass.CustomColorProperty"/> </Setter.Value> </Sett...

C#: Problem calling method inside a string property setter

I have a string property that defines a filename for an xml file. When the user inputs this filename into the property, I have the setter calling a parseXml() function immediatly after setting 'fileName = value' to populate a dataTable with the data from the XML file so it displays in the designer. For some reason, when I have this fun...

Can I implement rails setter and getter for attributes for db columns.

In rails we can access db column through attributes rails provided, but can we change this ? for example I have db with name column could I implement something like. def name "sir" + name end I tried it, but it result in stack overflow. There is a way to accomplish this. more question, Is there any difference between name and self....

Dynamically added glow effects to UIElement using triggers

Hey, Im new to wpf, and looking for good tutorials to help understand triggers better but im not having much luck. So i thought I would seek some help here. Here is what im trying to do, i have a ScrollViewer that has a stack panel, in the code behind I browse a media folder and added MediaElements to the stackpanel using a foreach loo...

WPF Set value by trigger when using binding

Why will not this work: <Button Width="200" Height="50"> <Button.Style> <Style TargetType="Button"> <Setter Property="Height" Value="{Binding RelativeSource={RelativeSource Self}, Path=Height}"/> <Setter Property="Background" Value="Blue"/> <Style.Triggers> <Trigger Property="Button.Is...

Objective-C :: using a method to change an object

I have a class called "CardSet", containing an NSMutableArray* cardSet to hold "cards", which I extend to make "DeckCards". I'd like "CardSet" to have a method called "(void)addCard:(Card*)" (and similarly a method "removeCard"). I'd like "addCard" to some how have access to and set cardSet. Even better I'd like to use the "addCard" meth...

Creating a setter method that takes extra arguments in Ruby

I'm trying to write a method that acts as a setter and takes some extra arguments besides the assigned value. Silly example: class WordGenerator def []=(letter, position, allowed) puts "#{letter}#{allowed ? ' now' : ' no longer'} allowed at #{position}" end def allow=(letter, position, allowed) # ... end end Writing i...

How do I alias the scala setter method 'myvar_$eq(myval)' to something more pleasing when in java?

I've been converting some code from java to scala lately trying to teach myself the language. Suppose we have this scala class: class Person() { var name:String = "joebob" } Now I want to access it from java so I can't use dot-notation like I would if I was in scala. So I can get my var's contents by issuing: person = Person.new(...

Ruby - How to remove a setter on an object

Given a class like this: class B class << self attr_accessor :var end end Suppose I can't modify the original source code of class B. How might I go about removing the setter on the class variable var? I've tried using something like B.send("unset_method", "var="), but that doesn't work (nor does remove_method, or ov...

Objective-C getter/ setter question

Hi, im trying to works my way trough an Objective-C tutorial. In the book there is this example: @interface { int width; int height; XYPoint *origin; } @property int width, height; I though, hey there's no getter/setter for the XYPoint object. The code does work though. Now i'm going maybe to answer my own question :). I thinks it...

Should a setter return immediately if assigned the same value?

In classes that implement INotifyPropertyChanged I often see this pattern : public string FirstName { get { return _customer.FirstName; } set { if (value == _customer.FirstName) return; _customer.FirstName = value; base.OnPropertyChanged("FirstName"); ...

Setting a value into a object using reflection

Hello I have an object that has a lot of attributes, each one with it's getter and setter. Each attribute has a non primitive type, that I don't know at runtime. For example, what I have is this: public class a{ private typeA attr1; private typeB attr2; public typeA getAttr1(){ return attr1; } public typeB getAttr2()...

Assigning a float to a decimal property via a style setter in WPF

I have the following xaml in a template for a lookless control: <Style x:Key="NumericUpDownStyle" TargetType="controls:NumericUpDown"> <Style.Setters> <Setter Property="Change" Value="{x:Static local:Preferences.ChangeAmount}"/> </Style.Setters> </Style> Where the 'Change' property on the 'NumericUpDown' control is a d...

How to change Hibernate´s auto persistance strategy

I just noted that my hibernate entities are automatically persisted to the database (or at least to cache) before I call any save() or update() method. To me this is a pretty strange default behavior but ok, as long as I can disable it, it´s fine. The problem I have is I want to update my entity´s state (from 1 to 2) only if the entity ...

C# - What should I do when every inherited class needs getter from base class, but setter only for ONE inherited class

Hello, I have a abstract class called WizardViewModelBase. All my WizardXXXViewModel classes inherit from the base abstract class. The base has a property with a getter. Every sub class needs and overrides that string property as its the DisplayName of the ViewModel. Only ONE ViewModel called WizardTimeTableWeekViewModel needs a se...

Binding Setter.Value from code

In XAML I can write something like this: <Setter Property="PropertyName" Value="{Binding ...}" /> How would I do this in code? I've constructed bindings in code before, but I can't seem to find any static ValueProperty object on the Setter class to pass to BindingOperations.SetBinding(). ...

Objective C difference between self.variable and variable assignments.

I fear I am being stupid. I've spent about three hours tracking down a memory leak that's been destroying my sanity and after commenting out half my app I have come to the following conclusion. Given the following in the right places. NSString *blah; @property (nonatomic, retain) NSString *blah; @synthesize blah; -(id)initWithBlah:...

Stack overflow exception in c# setter

Hi. This is simple to explain: this works using System; using ConstraintSet = System.Collections.Generic.Dictionary<System.String, double>; namespace ConsoleApplication2 { class test { public ConstraintSet a { get; set; } public test() { a = new ConstraintSet(); } static void ...

Is it possible to let Doctrine 1.2.2 generate getters and setters?

I'm looking for a way to let Doctrine generate getters and setters for me, because otherwise it will call the Doctrine_Record "get" method which costs a lot of time. so is there a chance to do that? ...

Conventions for accessor methods (getters and setters) in C++

Several questions about accessor methods in C++ have been asked on SO, but none was able satisfy my curiosity on the issue. I try to avoid accessors whenever possible, because, like Stroustrup and other famous programmers, I consider a class with many of them a sign of bad OO. In C++, I can in most cases add more responsibility to a cla...