【WPF】【Silverlight】Bindingでコントロールが突っ込めない?
- 2008.12.07 Sunday
- 13:07
WPFとSilverlightの微妙に違いに戸惑っています。
先ほど、Resharperが正しくうごいているかどうかチェックをしようと思い
下記のようなXAMLを書いてみました。
<UserControl x:Class="SilverlightApplication1.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<UserControl.Resources>
<TextBlock x:Key="textBlock" Text="TextBlock" />
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<ContentControl Content="{Binding Source={StaticResource textBlock}}" />
</Grid>
</UserControl>
Resharper4.0では
<UserControl.Resources>
<TextBlock x:Key="textBlock" Text="TextBlock" />
</UserControl.Resources>
の部分が問題があると指摘していたのですが、
これは恐らくSiliverlight2.beta2がResouceタグ内でCollectionを書かないと
いけない仕様だったのではないかと推測されます。
Reshaerper4.1では、問題ないと解釈してくれたので、とりあえずひと安心なのですが
なんと、このXAMLは実行時にXAMLからインスタンスを作成するタイミング(たぶん)で
ぶっこけてしまいます。
WPFだったらかけるんだけどなー
<Window x:Class="WpfApplication2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<TextBlock x:Key="textBlock" Text="TextBlock" />
</Window.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<ContentControl Content="{Binding Source={StaticResource textBlock}}" />
</Grid>
</Window>
先ほど、Resharperが正しくうごいているかどうかチェックをしようと思い
下記のようなXAMLを書いてみました。
<UserControl x:Class="SilverlightApplication1.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<UserControl.Resources>
<TextBlock x:Key="textBlock" Text="TextBlock" />
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<ContentControl Content="{Binding Source={StaticResource textBlock}}" />
</Grid>
</UserControl>
Resharper4.0では
<UserControl.Resources>
<TextBlock x:Key="textBlock" Text="TextBlock" />
</UserControl.Resources>
の部分が問題があると指摘していたのですが、
これは恐らくSiliverlight2.beta2がResouceタグ内でCollectionを書かないと
いけない仕様だったのではないかと推測されます。
Reshaerper4.1では、問題ないと解釈してくれたので、とりあえずひと安心なのですが
なんと、このXAMLは実行時にXAMLからインスタンスを作成するタイミング(たぶん)で
ぶっこけてしまいます。
WPFだったらかけるんだけどなー
<Window x:Class="WpfApplication2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<TextBlock x:Key="textBlock" Text="TextBlock" />
</Window.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<ContentControl Content="{Binding Source={StaticResource textBlock}}" />
</Grid>
</Window>