![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Variable assignment and clone or objet reference | PowerShell | |||
| Set Focus To Specific Property In Property Grid | .NET General | |||
| Verifier les messages sans objet missing object | Vista mail | |||