Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Bug: objet property not set (sample included)

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 06-09-2006   #1 (permalink)
Guillaume
Guest


 

Bug: objet property not set (sample included)

Hello,
I switch to beta 2 and found a strange bug with my code customizing the
expander template. First here is a code sample to demonstrate the bug (i'll
explain it after) :

<StackPanel>
<StackPanel.Resources>
<SolidColorBrush x:Key="SolidBorderBrush" Color="#FFFF0000" />

<Style TargetType="{x:Type Expander}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Expander}">
<ToggleButton>
<ToggleButton.Template>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<StackPanel Orientation="Horizontal">
<Canvas Width="24" Height="24" Margin="2,2,2,2">
<Ellipse Canvas.Left="1" Canvas.Top="1" Width="22"
Height="22" StrokeThickness="1" Stroke="#FFFF0000"/>
<Path Canvas.Left="8" Canvas.Top="9"
StrokeThickness="1" Stroke="#FF000000" Data="F1 M 0,0L 4,8L 8,0L 4,1 Z"/>
</Canvas>
<Canvas Width="24" Height="24" Margin="2,2,2,2">
<Ellipse Canvas.Left="1" Canvas.Top="1" Width="22"
Height="22" StrokeThickness="1" Stroke="{StaticResource SolidBorderBrush}"/>
<Path Canvas.Left="8" Canvas.Top="9"
StrokeThickness="1" Stroke="#FF000000" Data="F1 M 0,0L 4,8L 8,0L 4,1 Z"/>
</Canvas>
</StackPanel>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<StackPanel Orientation="Horizontal">
<Canvas Width="24" Height="24" Margin="2,2,2,2">
<Ellipse Canvas.Left="1" Canvas.Top="1" Width="22"
Height="22" StrokeThickness="1" Stroke="#FFFF0000"/>
<Path Canvas.Left="8" Canvas.Top="9" StrokeThickness="1"
Stroke="#FF000000" Data="F1 M 0,0L 4,8L 8,0L 4,1 Z"/>
</Canvas>
<Canvas Width="24" Height="24" Margin="2,2,2,2">
<Ellipse Canvas.Left="1" Canvas.Top="1" Width="22"
Height="22" StrokeThickness="1" Stroke="{StaticResource SolidBorderBrush}"/>
<Path Canvas.Left="8" Canvas.Top="9" StrokeThickness="1"
Stroke="#FF000000" Data="F1 M 0,0L 4,8L 8,0L 4,1 Z"/>
</Canvas>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</StackPanel.Resources>

<Expander x:Name="myExpander" />
<ToggleButton x:Name="myToggleButton" />
</StackPanel>

This sample should display 4 ellipse (2 for the expander and 2 for the
togglebutton) with an arrow inside each but if you try it you will find that
the second ellipse of the expander doesn't have an arrow.
The difference between the 2 shapes is simple : the first ellipse has a
"constant" color #FFFF0000 and the second uses a SolidColorBrush with the
same color.
The togglebutton is there to demonstrate that the but doesn't occure if the
template is applied directly on it but occures only if it's applied on a
togglebutton inside another template.

I looked with the debugger to find why the arrow after the ellipse with a
SolidColorBrush doesn't render and i found that its properties are not sets !

You can use those strings in the watch window to see this :

expander first path (OK) : ((Path) ((UIElement)
this.FindName("myExpander")).GetVisualChild(0).GetVisualChild(0).GetVisualChild(0).GetVisualChild(1)).Data

expander second path (KO) : ((Path) ((UIElement)
this.FindName("myExpander")).GetVisualChild(0).GetVisualChild(0).GetVisualChild(1).GetVisualChild(1)).Data

togglebutton first path (OK) : ((Path) ((UIElement)
this.FindName("myToggleButton")).GetVisualChild(0).GetVisualChild(0).GetVisualChild(1)).Data

togglebutton second path (OK) : ((Path) ((UIElement)
this.FindName("myToggleButton")).GetVisualChild(0).GetVisualChild(1).GetVisualChild(1)).Data

So can someone a microsoft can look into this ?

Thanks,
Guillaume

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Use my custom TypeDescriptor to obtains default Value on property inXAML Property Editor of Visual Studio 2008 azerty Avalon 0 04-14-2008 06:14 AM
Verifier les messages sans objet missing object YbeV Vista mail 1 10-20-2007 11:08 AM
Sample Music TipTop Vista music pictures video 0 07-03-2007 12:02 PM
Sample Music Travis King Vista General 4 06-11-2007 10:31 AM


Vistax64.com 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 2005-2008

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 47 48 49 50 51