Problem with customize window header.

4 posts, 1 answers
  1. Sergiy
    Sergiy avatar
    38 posts
    Member since:
    Jan 2012

    Posted 14 Sep 2012 Link to this post

    Hi, I try to customize Window Header and add some  textblock (see atach).

    <t:RadWindow.HeaderTemplate>
        <DataTemplate>
            <Grid Margin="10,0">
                <ContentPresenter Content="{Binding}" HorizontalAlignment="Left"/>
                <TextBlock x:Name="txtblk" Text="XAML" Opacity="0.4" FontSize="16" HorizontalAlignment="Right">
                    <TextBlock.Triggers>
                        <EventTrigger RoutedEvent="TextBlock.MouseEnter">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName="txtblk"
                                        Storyboard.TargetProperty="(TextBlock.Opacity)"
                                        From="0.4" To="1" Duration="0:0:0.5"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </TextBlock.Triggers>
                </TextBlock>
            </Grid>
        </DataTemplate>
    </t:RadWindow.HeaderTemplate>

    But it works when TextBlock FontSize is 20 or more for instance. When I set FontSize to 16, triggers or doubleanimation don't work.
    Why?
    How to solve this problem?
    Thanks.
  2. Answer
    Georgi
    Admin
    Georgi avatar
    347 posts

    Posted 18 Sep 2012 Link to this post

    Hi Sergiy,

    There is a part of the RadWindows header which does not register events like MouseEnter, but setting the Font to 20 overcomes that area and therefore the animation is working. So all you need to do is set the WindowHost.HitTestable attached property to true:

    <DataTemplate>
                <Grid Margin="10,0">
                    <ContentPresenter Content="{Binding}" HorizontalAlignment="Left"/>
                    <TextBlock x:Name="txtblk" Text="XAML" Opacity="0.4" FontSize="16" HorizontalAlignment="Right" telerik:WindowHost.HitTestable="True">     
    .......................................................

    It would be great if you can give it a try and let us know if it works for you.

    Regards,
    Georgi
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Sergiy
    Sergiy avatar
    38 posts
    Member since:
    Jan 2012

    Posted 19 Sep 2012 Link to this post

    Thanks, it`s works, but I already using simple button with custom style.
    Could you explain how it works? (telerik:WindowHost.HitTestable="True")
  5. Georgi
    Admin
    Georgi avatar
    347 posts

    Posted 21 Sep 2012 Link to this post

    Hello Sergiy,

    In the described scenario the events are handled by the Windows, not by the WPF. But when the HitTestVisible is set to true the event is send to WPF instead - it finds the element that the property is set to and executes the corresponding logic.

    Kind regards,
    Georgi
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

Back to Top