On 28 Oct 2013, at 17:52, Gerd Knops <[email protected]> wrote:

> In Interface Builder text fields you can use "Value with Pattern" to combine 
> multiple properties into a single output. Alternatively in code you can do 
> something like this:
> 
> - (NSString *)fullName {
>       
>       return [NSString stringWithFormat:@"%@, 
> %@",self.lastName,self.firstName];
> }
> + (NSSet *)keyPathsForValuesAffectingFullName {
>       
>       return [NSSet setWithObjects:@"lastName",@"firstName",nil];
> }
> 
> Gerd
> 

Thanks Gerd

Value with Pattern works as advertised for NSTextField.
Unfortunately I am binding to an NSPopupButton which lacks this binding.

XAML bindings, though similar in nature to Cocoa bindings, are somewhat more 
flexible I think.
The following illustrates more or less what I need to emulate.

The converter (eqv to the value transformer) operates on self.name and 
PeriodTypeComboBox.SelectedItem.Name

<ComboBox.ItemTemplate>
        <DataTemplate>
                <TextBlock>
                        <Run>Based on a</Run>
                        <Run>
                                <Run.Text>
                                        <MultiBinding 
Converter="{StaticResource StringReplaceConverter}" ConverterParameter="Period">
                                                <Binding Path="Name" />
                                                <Binding 
ElementName="PeriodTypeComboBox" Path="SelectedItem.Name" />
                                        </MultiBinding>
                                </Run.Text>
                        </Run>
                </TextBlock>
        </DataTemplate>
</ComboBox.ItemTemplate>

Jonathan
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to