Skip to main content

Microsoft Silverlight

Answered Question Fail to edit template of my custom control in blendRSS Feed

(0)

Dioman
Dioman

Member

Member

6 points

9 Posts

Fail to edit template of my custom control in blend

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...

Dioman
Dioman

Member

Member

6 points

9 Posts

Re: Fail to edit template of my custom control in blend

any ideas? 

jasonxz
jasonxz

Participant

Participant

1752 points

530 Posts

Re: Fail to edit template of my custom control in blend

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?

Dioman
Dioman

Member

Member

6 points

9 Posts

Re: Fail to edit template of my custom control in blend

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>

Dioman
Dioman

Member

Member

6 points

9 Posts

Re: Re: Fail to edit template of my custom control in blend

any ideas? 

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Re: Fail to edit template of my custom control in blend

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: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>

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

Dioman
Dioman

Member

Member

6 points

9 Posts

Re: Re: Fail to edit template of my custom control in blend

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

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Answered Question

Re: Re: Re: Fail to edit template of my custom control in blend

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.

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities