Pin main window to taskbar

8 posts, 0 answers
  1. Richard Harrigan
    Richard Harrigan avatar
    235 posts
    Member since:
    Nov 2009

    Posted 07 Aug 2013 Link to this post

    Hi,

    I picked up the following code from the forum that enables my application to be placed in the task bar with the Icon that  i referenced.  This works well but if I pin the app to the taskbar the icon reverts back to the icon that normally shows in the microsoft main window.  How can I get my icon to persit when being pinned to the taskbar,  Also, while I am asking for help on the icon, how do I get the icon to also show in the window header.

    Thanks
    Rich


    public void ShowInTaskbar(RadWindow control, string title)
            {
                control.Show();
                var window = control.ParentOfType<Window>();
                window.ShowInTaskbar = true;
                window.Title = title;
                var uri = new Uri("pack://application:,,,/Images/myapp.png");
                window.Icon = BitmapFrame.Create(uri);
            }
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 13 Aug 2013 Link to this post

    Hello,

    We are not aware of such issues when setting the icon of the RadWindow and minimizing it to the taskbar. It is possible that you haven't set application icon or you are running the application in debug mode. In that mode the application icon is not show.

    I recorded a short video for you showing how to show the icon in the RadWindow title and in the taskbar, hope this is helpful. You can also find a sample project that demonstrates the approach seen in the video attached to my response.

    Regards,
    Vladi
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Richard Harrigan
    Richard Harrigan avatar
    235 posts
    Member since:
    Nov 2009

    Posted 19 Sep 2013 Link to this post

    Hi Vladi,

    Could you modify this code to show the RadWindow created in the Xaml file.  Also I could't get the project into Visual Studio to test.  I am using Visual Studio 2012 Express.  I tried using your code as a guide except that my RadWindow (MainWindow) is created in xaml.  I got the same results as before.  While running the correct icon displays in the task bar but when I close the app it reverts back to the default icon.

    Thanks
    Rich
  5. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 20 Sep 2013 Link to this post

    Hi,

    I am not sure what you mean by created in the xaml RadWindow. If you mean that you have a UserControl that is of RadWindow type and you are settings its properties in the xaml, in order to set the icon you will need to set it like this:
    <telerik:RadWindow ...>
        <telerik:RadWindow.Icon>
                <Image Source="my_app_window_icon.jpg"/>
        </telerik:RadWindow.Icon>
        ...
    </telerik:RadWindow>

    I attached a sample project and a short video for you showing that the icon is set correctly after pinning the RadWindow to the taskbar. Hope this is helpful.

    Regards,
    Vladi
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Richard Harrigan
    Richard Harrigan avatar
    235 posts
    Member since:
    Nov 2009

    Posted 24 Sep 2013 Link to this post

    Hi  Vladi,

    Your example is not quite the same as what I am trying to do.

    ******** Your main window ***************

    Window x:Class="WindowTaskbarIconTest.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <StackPanel>
            <Button Content="Open RadWindow" Click="Button_Click" VerticalAlignment="Center" HorizontalAlignment="Center"/>
            <Button Content="Open MyRadWindow UserControl" Click="Button_Click_1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
            <Image Source="C:\WPF Projects\WindowTaskbarIconTest\WindowTaskbarIconTest\Images\my_app_window_icon.jpg" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="24" Height="24"/>
        </StackPanel>
    </Window>

    ========================================================================================================

    *********** My main window ******************

    <telerik:RadWindow
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="Cloudburst.QueryMaker.MainWindow"
            xmlns:local="clr-namespace:Cloudburst.QueryMaker"
            Header=" SQL Writer" Height="675" Width="1100" 
            WindowStartupLocation="CenterScreen" 
            Name="cloudburstWriter"
            WindowState="Normal"
            Loaded="Window_Loaded">
        <telerik:RadWindow.Icon>
            <Image Source="/Icons/16/results.png"/>
        </telerik:RadWindow.Icon>

    ============================================================================

    I tried to assimilate your example by executing the following from the Window_Loaded event. 
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
    this.ShowInTaskbar(this.cloudburstWriter, "Sql Writer");
    }

     I can pin the the app to the taskbar but is shows a default icon,  not the icon displayed in the window header.  I used a release build and invoked from windows explorer.  Is it possible that it does not work when the main window is a telerik,RadWindow instead of a Window.  If possible can you change you example to where the main window is also a telerik.RadWindow.

    Thanks
    Rich
  7. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 25 Sep 2013 Link to this post

    Hi,

    The icon that is displayed in the taskbar of the MainWindow is the icon that is set in the Application Properties of the project rather then the one set to the icon of the RadWindow. When using RadWindow as MainWindow make sure that icon of the application is set in order to be able to see it in the taskbar.

    I created and attached a sample project for you that shows that the icon is displayed correctly. Make sure that you run the project out of the debug mode (Ctrl+F5) because in it the application icon is not displayed.

    Regards,
    Vladi
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  8. Richard Harrigan
    Richard Harrigan avatar
    235 posts
    Member since:
    Nov 2009

    Posted 25 Sep 2013 Link to this post

    Hi Vladi

    I could not get your sample into windows 8, visual studio 2012 express.  Could you provide your sample with a visual studio solution file.  I modified my xaml file as shown in your example ( see below).  The icon did not show up in the taskbar.  I'm  still getting the default icon.  In your example the file 'my_app.ico' did not seem to be referenced anywhere.  Is that the icon that is supposed to show up in the taskbar?

    Thanks
    Rich

    <telerik:RadWindow
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="Cloudburst.QueryMaker.MainWindow"
            xmlns:local="clr-namespace:Cloudburst.QueryMaker"
            Header=" SQL Writer" Height="675" Width="1100" 
            WindowStartupLocation="CenterScreen" 
            Name="cloudburstWriter"
            WindowState="Normal"
            xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls.Navigation;assembly=Telerik.Windows.Controls.Navigation"
    telerikNavigation:RadWindowInteropHelper.ShowInTaskbar="True"

            Loaded="Window_Loaded">
        <telerik:RadWindow.Icon>
            <Image Source="/Icons/32/apply.ico"/>
        </telerik:RadWindow.Icon>
  9. Richard Harrigan
    Richard Harrigan avatar
    235 posts
    Member since:
    Nov 2009

    Posted 25 Sep 2013 Link to this post

    Hi Vladi,

    I reread your last post and changed the icon in the application icon property page, all is well, I hadn't changed this property before and therefore did not interpret you post correctly.

    Thanks for staying with me.
    Rich
Back to Top
UI for WPF is Visual Studio 2017 Ready