差分
ページの作成:「Interface Builderとソースコードを連動させるCocoa Bindingの使い方を調査している。 Xamarin.MacのBindingライブラリ(いわゆるP/I...」
[[Interface Builder]]と[[ソースコード]]を連動させるCocoa Bindingの使い方を調査している。
Xamarin.MacのBindingライブラリ(いわゆるP/Invokeみたいなもの)とは「バインディング」という名称はにているがまったくの別物である。
==実装1==
#バインディング用のプロパティを用意する。
#Export属性でInterface Builderから見た場合の名称を与える。
#WillChangeValueメソッドおよびDidChangeValueメソッドでプロパティの変更を伝える。
この例では配列を作るのが面倒だったのでAVFoundationのビデオ入力デバイス一覧を使っている。FaceTimeカメラなんかが列挙されるはず。
<source lang="csharp">
AVCaptureDevice[] _videoDevices;
[Export("videoDevices")]
public AVCaptureDevice[] VideoDevices
{
get { return _videoDevices; }
set
{
if (_videoDevices != value)
{
WillChangeValue("videoDevices");
_videoDevices = value;
DidChangeValue("videoDevices");
}
}
}
public override void WindowDidLoad()
{
base.WindowDidLoad();
this.VideoDevices = AVCaptureDevice.DevicesWithMediaType(AVMediaType.Video);
}
</source>
Interface Builderを開きバインディングを設定する。
#Bindings Inspectorを開く
#Value Selection
#*Content
#**Bind to 「Files's Owner」を選びチェック
#**Model Key Path 「videoDevices」(Exportで指定したプロパティ名称)
#**null許容の場合は「Inserts Null Placeholder」にチェック
#*Content Values
#**Bind to 「Files's Owner」を選びチェック
#**Model Key Path 「videoDevices.localizedName」(Exportで指定したプロパティのプロパティが表示名となる)
#*null許容の場合は「Inserts Null Placeholder」にチェック
自動選択を使う場合は「Selected〜」系にも値を埋める。
==関連項目==
==参考文献==
{{reflist}}
{{stub}}
[[category:Xamarin.Mac]]
[[category:MonoMac]]
Xamarin.MacのBindingライブラリ(いわゆるP/Invokeみたいなもの)とは「バインディング」という名称はにているがまったくの別物である。
==実装1==
#バインディング用のプロパティを用意する。
#Export属性でInterface Builderから見た場合の名称を与える。
#WillChangeValueメソッドおよびDidChangeValueメソッドでプロパティの変更を伝える。
この例では配列を作るのが面倒だったのでAVFoundationのビデオ入力デバイス一覧を使っている。FaceTimeカメラなんかが列挙されるはず。
<source lang="csharp">
AVCaptureDevice[] _videoDevices;
[Export("videoDevices")]
public AVCaptureDevice[] VideoDevices
{
get { return _videoDevices; }
set
{
if (_videoDevices != value)
{
WillChangeValue("videoDevices");
_videoDevices = value;
DidChangeValue("videoDevices");
}
}
}
public override void WindowDidLoad()
{
base.WindowDidLoad();
this.VideoDevices = AVCaptureDevice.DevicesWithMediaType(AVMediaType.Video);
}
</source>
Interface Builderを開きバインディングを設定する。
#Bindings Inspectorを開く
#Value Selection
#*Content
#**Bind to 「Files's Owner」を選びチェック
#**Model Key Path 「videoDevices」(Exportで指定したプロパティ名称)
#**null許容の場合は「Inserts Null Placeholder」にチェック
#*Content Values
#**Bind to 「Files's Owner」を選びチェック
#**Model Key Path 「videoDevices.localizedName」(Exportで指定したプロパティのプロパティが表示名となる)
#*null許容の場合は「Inserts Null Placeholder」にチェック
自動選択を使う場合は「Selected〜」系にも値を埋める。
==関連項目==
==参考文献==
{{reflist}}
{{stub}}
[[category:Xamarin.Mac]]
[[category:MonoMac]]