Re: MultiBinding
Re: MultiBinding
On 28 Oct 2013, at 17:52, Gerd Knops <email@hidden> 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@hidden)
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:
This email sent to email@hidden