469,903 Members | 1,991 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

WPF Binding issue

Hi,

I'm trying to understand why something does work. If you create a new
WPF Applicatin project, WpfApplication6, and set the following:

MainWindow.xaml:
<Window x:Class="WpfApplication6.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:app="clr-namespace:WpfApplication6"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<ObjectDataProvider
x:Key="ObjData"
IsInitialLoadEnabled="True"
ObjectType="{x:Type app:DummyClass}"
IsAsynchronous="True"
/>
</Window.Resources>

<StackPanel>
<app:UserControl1 Dummy="{Binding Source={StaticResource ObjData},
Path=Data, BindsDirectlyToSource=True}" />
</StackPanel>
</Window>

Add a UserControl named UserControl1:
<UserControl x:Class="WpfApplication6.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:app="clr-namespace:WpfApplication6"
>
<x:Code>
<![CDATA[
public static readonly DependencyProperty DummyProperty =
DependencyProperty.Register( "Dummy", typeof( DummyClass ),
typeof( UserControl1 ) );

public DummyClass Dummy {
get { return (DummyClass)GetValue( DummyProperty ); }
set { SetValue( DummyProperty, value ); }
}
]]>
</x:Code>

<TextBlock Text="{Binding RelativeSource={RelativeSource
FindAncestor, AncestorType={x:Type app:UserControl1}},
Path=Dummy.MyProperty}" />

</UserControl>

And a class, DummyClass:
public class DummyClass {
public string MyProperty { get { return "My Text!"; } }
}
And run the program... the text is never displayed. If the
DataProvider is set not to be asyncronous, it works... but shouldn't
the property Data being changed when IsAsync = true cause the binding
to refresh?

Thanks
Andy
Oct 16 '08 #1
0 1183

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by JD Kronicz | last post: by
30 posts views Thread by lgbjr | last post: by
9 posts views Thread by Miro | last post: by
6 posts views Thread by Mikus Sleiners | last post: by
6 posts views Thread by Dmitry Duginov | last post: by
6 posts views Thread by Tomasz J | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.