Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Cannot retrieve the visualtree from a datatemplate

 
 
Old 02-01-2007   #1 (permalink)
Pon


 
 

Cannot retrieve the visualtree from a datatemplate

Hi evrybody,

I'm trying to set a databinding on a gridview column which have a
celltemplate.
This celltemplate is retrieved from a ressource defined in the form XAML
code.
To do that i tried the following in the form codebehind :
DataTemplate MyDataTemplate= this.FindResource("MyDataTemplateKey")

There, everythings seems normal as MyDataTemplate is not null.

But when i cannot walk the MyDataTemplate visualtree cause
MyDataTemplate.Visualtree is null.

Here is the code of the datatemplate :

<DataTemplate x:Key="MyDataTemplateKey">
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock x:Name="Txtbk_Cpte">xxxxx</TextBlock>
<Button Margin="2,0,0,0">
<Image Source="C:\xxxx\xxxx.ico" Height="14"/>
</Button>
</StackPanel>
</DataTemplate>

What do I do wrong ?

Thanx in advance.




My System SpecsSystem Spec
Old 02-01-2007   #2 (permalink)
Pon


 
 

Re: Cannot retrieve the visualtree from a datatemplate

Got it. I used loadcontent.


"Pon" <pongla.public@laposte.net> wrote in message
news:%23fDznmgRHHA.388@TK2MSFTNGP04.phx.gbl...
> Hi evrybody,
>
> I'm trying to set a databinding on a gridview column which have a
> celltemplate.
> This celltemplate is retrieved from a ressource defined in the form XAML
> code.
> To do that i tried the following in the form codebehind :
> DataTemplate MyDataTemplate= this.FindResource("MyDataTemplateKey")
>
> There, everythings seems normal as MyDataTemplate is not null.
>
> But when i cannot walk the MyDataTemplate visualtree cause
> MyDataTemplate.Visualtree is null.
>
> Here is the code of the datatemplate :
>
> <DataTemplate x:Key="MyDataTemplateKey">
> <StackPanel Orientation="Horizontal" Margin="2">
> <TextBlock x:Name="Txtbk_Cpte">xxxxx</TextBlock>
> <Button Margin="2,0,0,0">
> <Image Source="C:\xxxx\xxxx.ico" Height="14"/>
> </Button>
> </StackPanel>
> </DataTemplate>
>
> What do I do wrong ?
>
> Thanx in advance.
>
>
>



My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
DataTemplate .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46