Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Fail to edit template of my custom control in blend
7 replies. Latest Post by Yi-Lun Luo - MSFT on June 20, 2008.
(0)
Dioman
Member
6 points
9 Posts
06-18-2008 4:06 AM |
Hi,
I have problem with editing my custom control in blend. I've created it with best practices, it contains TamplateParts contract, and everything works well accept editing it in Blend. It throws me: E_Fail....com.. exception. Has anybody faced with this? maybe it's just a beta2 bug...
06-18-2008 11:12 AM |
any ideas?
jasonxz
Participant
1752 points
530 Posts
06-18-2008 1:28 PM |
Can you post the xaml for your style?
When does Blend throw the exception; when you load the control or as a result of another action?
06-19-2008 3:17 AM |
Blend throws exeption after I select Edit empty template on my control placed somewhere on test page. Not actually the message box, but it draws it within control's border.
Here is my generic xaml, it's big, so I show only the meaning part
<ResourceDictionary xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:UI="clr-namespace:UI;assembly=UI" xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" >
... helper style <Style TargetType="Button" x:Key="scrollerStyle"> <Setter Property="IsEnabled" Value="true" />...setters <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Grid> <vsm:VisualStateManager.VisualStateGroups> <vsm:VisualStateGroup x:Name="FocusStates"> .. vsm like button has </vsm:VisualStateManager.VisualStateGroups> <Path Data="{TemplateBinding Tag}" Fill="#FF1041C6" Stretch="Fill" x:Name="path"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
... the thing! default style for scroller <Style TargetType="UI:Scroller"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="UI:Scroller"> <Grid Background="{TemplateBinding Background}"> <UI:ScrollerContent x:Name="scrollContent" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Cursor="{TemplateBinding Cursor}" Background="{TemplateBinding Background}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" TextAlignment="{TemplateBinding TextAlignment}" TextDecorations="{TemplateBinding TextDecorations}" TextWrapping="{TemplateBinding TextWrapping}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" /> <Button x:Name="upButton" Tag="M0,0 L-1,1 L1,1z" Style="{StaticResource scrollerStyle}" VerticalAlignment="Top"/> <Button x:Name="downButton" Tag="M0,0 L-1,-1 L1,-1z" Style="{StaticResource scrollerStyle}" VerticalAlignment="Bottom"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style></ResourceDictionary>
06-19-2008 8:24 AM |
Yi-Lun L...
All-Star
25052 points
2,747 Posts
06-20-2008 1:00 AM |
Hello, can you also post some code? Just tried this and it works fine. I see two triangles.
public class Scroller : ContentControl{public Scroller(){this.DefaultStyleKey = typeof(Scroller);}}public class ScrollerContent : ContentControl{ }
<Style TargetType="Button" x:Key="scrollerStyle"><Setter Property="IsEnabled" Value="true" /><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="Button"><Grid><vsm:VisualStateManager.VisualStateGroups><vsm:VisualStateGroup x:Name="FocusStates"/></vsm:VisualStateManager.VisualStateGroups><Path Data="{TemplateBinding Tag}" Fill="#FF1041C6" Stretch="Fill" x:Name="path"/></Grid></ControlTemplate></Setter.Value></Setter></Style><Style TargetType="UI:Scroller"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="UI:Scroller"><Grid Background="{TemplateBinding Background}"><UI:ScrollerContentx:Name="scrollContent"Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"Cursor="{TemplateBinding Cursor}"Background="{TemplateBinding Background}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}"FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}"FontWeight="{TemplateBinding FontWeight}"Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"TextAlignment="{TemplateBinding TextAlignment}"TextDecorations="{TemplateBinding TextDecorations}" TextWrapping="{TemplateBinding TextWrapping}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"Margin="{TemplateBinding Padding}" /><Button x:Name="upButton" Tag="M0,0 L-1,1 L1,1z" Style="{StaticResource scrollerStyle}" VerticalAlignment="Top"/><Button x:Name="downButton" Tag="M0,0 L-1,-1 L1,-1z" Style="{StaticResource scrollerStyle}" VerticalAlignment="Bottom"/></Grid></ControlTemplate></Setter.Value></Setter></Style>
06-20-2008 2:54 AM |
But problem is, that I cant edit template of this component.
Actions:
Place this custom control on test Page.xaml, and choose in Blend "Edit Template" on this
06-20-2008 2:58 AM |
Currently Blend doesn't support copy ControlTemplate that are not define in System.Windows.dll. But you should be able to create an empty template and edit it.