What happened to transparency on window drag/move?

4 posts, 0 answers
  1. Dan
    Dan avatar
    9 posts
    Member since:
    Oct 2008

    Posted 05 Dec 2008 Link to this post

    I thought that was a slick looking visual.

    I was looking to implement it myself, but found it's not currently possible (or at the very least, obvious).

    All of the mouse events on the window fire for the content area only so I can't trap it that way (which is normally fine, and I understand you're probably reserving header mouse captures to manage window movement as well as drag/drop).

    The closest I can get is to subscribe to LocationChanged and change the opacity there, but there doesn't appear to be an obvious way to detect when the window has stopped moving to restore the opacity back to full.

    A property on the window called "OpacityDuringMove" would be nice (to mimic the pre-commercial release).  Or exposing HeaderMouseUp/Down properties so the user could implement it would work too.

    Thanks!
    Dan
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 08 Dec 2008 Link to this post

    Hi Dan,

    In the last moment our designers decided that the windows should not become transparent when they are moved and we dropped that feature. It is actually relatively easy to implement by modifying the control template of RadWindow. Find attached a simple application that demonstrates how to do it.

    The main idea is to copy the RadWindow control template to your application or a separate project, modify it and then set RadWindow to use it. Since we still do not provide the templates of the controls in our distribution (we will with SP2, scheduled for the next week), you should follow the steps below:
    1) Open Telerik.Windows.Controls.Navigation.dll with Reflector, expand its node, expand Resources, select Telerik.Windows.Navigation.g.resources
    2) Right-click on window.xaml from the right hand part of the screen and click Save As... and save the file to the folder of your application.
    3) In Visual Studio include the new file in the application.
    4) Open Window.xaml and search for "RadWindow_ControlTemplate".
    5) Change the "Dragging" visual state and save the file:
    <ControlTemplate x:Key="RadWindow_ControlTemplate" TargetType="telerikNavigation:RadWindow">
    <ContentControl>
      <vsm:VisualStateManager.VisualStateGroups>
       <vsm:VisualStateGroup x:Name="Animation">
        <vsm:VisualState x:Name="Dragging">
         <Storyboard>
          <DoubleAnimation Storyboard.TargetName="LayoutGrid"
            Storyboard.TargetProperty="(UIElement.Opacity)"
            Duration="0:0:0.2" To="0.5" />
         </Storyboard>
        </vsm:VisualState>

        ...
    </ControlTemplate>

    6) In the user control where RadWindow is declared add the following:
    <UserControl x:Class="SilverlightApplication1.SilverlightControl1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
      xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation">
     <UserControl.Resources>
      <telerik:Theme Source="/SilverlightApplication1;component/themes/window.xaml"
        x:Key="WindowTheme1" />
     </UserControl.Resources>
     <Grid x:Name="LayoutRoot" Background="White">
      <Button Content="Show window" Click="Button_Click" Width="200" Height="30" />

      <telerikNavigation:RadWindow Width="200" Height="200" x:Name="window1"
        telerik:RadControl.Theme="{StaticResource WindowTheme1}">
      </telerikNavigation:RadWindow>

     </Grid>
    </UserControl>

    And this is it.

    Please, let me know if you have problems running the sample or need additional information.

    Sincerely yours,

    Valeri Hristov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Dan
    Dan avatar
    9 posts
    Member since:
    Oct 2008

    Posted 08 Dec 2008 Link to this post

    Hey Valeri
    Thanks for the assistance. I didn't have any luck getting your sample running. 

    It was having some parse errors in building the resource.  Once I got around that, I ran into a problem with this part of window.xaml:

        <telerik:ResourceDictionary.MergedDictionaries> 
            <telerik:ResourceDictionary Keys="ButtonStyle  
                                        Collapsed  
                                        Visible  
                                        InputTextBoxStyle  
                                        RadWindowInnerBorder  
                                        RadWindowInnerMostBorder  
                                        RadWindowInnerBackground  
                                        RadWindowOuterBackground  
                                        RadWindowOuterBorder  
                                        BorderOuterBrush  
                                        BorderInnerBrush  
                                        InputTextBoxBackground  
                                        "  
                    Source="/Telerik.Windows.Controls;component/Themes/Common.xaml" /> 
        </telerik:ResourceDictionary.MergedDictionaries> 

    It doesn't appear to be able to access the Keys in the specified Telerik assembly. (I get a bad property exception)

    Perhaps those values do not provide access outside of the Telerik assembly?
  4. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 09 Dec 2008 Link to this post

    Hello Dan,

    I suppose that you are using different version of the assemblies than the one that I used for the example. I used the distribution with the CTP of RadGridView for Silverlight and I suppose that if you upgrade to that version the example will run without errors.

    If you cannot run my example using any of the RadControls assemblies you have, I suggest following the steps I provided and recreating the example manually.

    Kind regards,
    Valeri Hristov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top