Page view counter
Fail to edit template of my custom control in blend Subscribe to this thread
Last post 06-20-2008 2:58 AM by Yi-Lun Luo - MSFT. 7 replies.
Sort Posts:
06-18-2008 4:06 AM
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

Loading...
Joined on 06-09-2008
Posts 9
06-18-2008 11:12 AM
Re: Fail to edit template of my custom control in blend

any ideas? 

Dioman

Loading...
Joined on 06-09-2008
Posts 9
06-18-2008 1:28 PM
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?

jasonxz

Loading...
Joined on 04-17-2007
Arlington, TX
Posts 526
06-19-2008 3:17 AM
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

Loading...
Joined on 06-09-2008
Posts 9
06-19-2008 8:24 AM
Re: Re: Fail to edit template of my custom control in blend

any ideas? 

Dioman

Loading...
Joined on 06-09-2008
Posts 9
06-20-2008 1:00 AM
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.

Yi-Lun Luo - MSFT

Loading...
Joined on 10-29-2007
Posts 2,747
06-20-2008 2:54 AM
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

Dioman

Loading...
Joined on 06-09-2008
Posts 9
06-20-2008 2:58 AM
Marked as Answer
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.

Yi-Lun Luo - MSFT

Loading...
Joined on 10-29-2007
Posts 2,747
Microsoft Communities