• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MultiBinding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MultiBinding


  • Subject: Re: MultiBinding
  • From: "email@hidden" <email@hidden>
  • Date: Mon, 28 Oct 2013 20:35:22 +0000

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


  • Follow-Ups:
    • Re: MultiBinding
      • From: "email@hidden" <email@hidden>
References: 
 >MultiBinding (From: "email@hidden" <email@hidden>)
 >Re: MultiBinding (From: Gerd Knops <email@hidden>)

  • Prev by Date: Re: MultiBinding
  • Next by Date: NSWindow Level Side Effect - PopUp to Normal
  • Previous by thread: Re: MultiBinding
  • Next by thread: Re: MultiBinding
  • Index(es):
    • Date
    • Thread