This is a migrated thread and some comments may be shown as answers.
Setting window icon with resource
4 Answers 64 Views
This is a migrated thread and some comments may be shown as answers.
Gilbert van Veen
Top achievements
Rank 1
Gilbert van Veen asked on 30 Dec 2009, 02:06 PM
I can't set the icon, based on a resource.

The error tells my "Can't find resource key IconTemplate".

This is my code:
<telerikNavigation:RadWindow  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
    xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
    xmlns:localCommon="clr-namespace:GaSuite" 
    x:Class="GaSuite.Dep_EditWindow" 
    Width="400" Height="Auto" 
    mc:Ignorable="d" 
    Icon="/Images/department.png"                          
    IconTemplate="{StaticResource IconTemplate}"   
    >     
    <Grid x:Name="LayoutRoot" Background="White">  
        <Grid.Resources> 
            <localCommon:ExtConverter x:Key="StringToImageSourceConverter" /> 
            <DataTemplate x:Key="IconTemplate">  
                <Image Source="{Binding Converter={StaticResource StringToImageSourceConverter}}" /> 
            </DataTemplate> 
        </Grid.Resources> 
        <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="0.438*"/>  
            <ColumnDefinition Width="0.562*"/>  
        </Grid.ColumnDefinitions> 
          
        <Grid Margin="8,8,8,8" Grid.ColumnSpan="2" > 
            <Grid.ColumnDefinitions> 
                <ColumnDefinition Width="150"></ColumnDefinition> 
                <ColumnDefinition></ColumnDefinition>  
            </Grid.ColumnDefinitions> 
            <Grid.RowDefinitions> 
                <RowDefinition Height="30"/>                  
                <RowDefinition Height="30"/>  
                <RowDefinition Height="30"/>  
                <RowDefinition Height="30"/>                  
                <RowDefinition Height="*"/>  
            </Grid.RowDefinitions> 
              
            <TextBlock Grid.Row="1" Grid.Column="0" Text="Id" VerticalAlignment="Bottom"></TextBlock> 
            <TextBlock Grid.Row="2" Grid.Column="0" Text="Nummer" VerticalAlignment="Bottom"></TextBlock> 
            <TextBlock Grid.Row="3" Grid.Column="0" Text="Omschrijving" VerticalAlignment="Bottom"></TextBlock> 
              
            <TextBox x:Name="Dep_Id" Grid.Row="1" Grid.Column="1" Text="{Binding Id}" AcceptsReturn="True" Width="150" IsEnabled="False" Height="25" Margin="0" HorizontalAlignment="Left" /> 
            <TextBox x:Name="Dep_Number" Grid.Row="2" Grid.Column="1" Text="{Binding Number, Mode=TwoWay}" AcceptsReturn="True" Width="150" Height="25" MaxLength="15" Margin="0" HorizontalAlignment="Left" /> 
            <TextBox x:Name="Dep_Description" Grid.Row="3" Grid.Column="1" Text="{Binding Description, Mode=TwoWay}" AcceptsReturn="True" Width="150" Height="25" MaxLength="50" Margin="0" HorizontalAlignment="Left" />          
            <Button x:Name="OKButton" Grid.Row="4" Grid.Column="1" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,8,101,19"/>  
            <Button x:Name="CancelButton" Grid.Row="4" Grid.Column="1" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,8,22,19"/>              
        </Grid> 
    </Grid> 
</telerikNavigation:RadWindow> 

I think I am missing something here.

Hope someone helpes me out.

4 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 30 Dec 2009, 02:29 PM
Hi Gilbert,

 Could you please try to move the DataTemplate with x:Key set to IconTemplate to the resources of the RadWindow or set the IconTemplate property directly (without using resources).

If you have further questions we will be happy to assist you.

Best wishes,
Miroslav Nedyalkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Gilbert van Veen
Top achievements
Rank 1
answered on 30 Dec 2009, 02:43 PM
<telerikNavigation:RadWindow  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
    xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
    xmlns:localCommon="clr-namespace:GaSuite" 
    x:Class="GaSuite.Dep_EditWindow" 
    Width="400" Height="Auto" 
    mc:Ignorable="d" 
    Icon="/Images/department.png" 
    IconTemplate = "{StaticResource IconTemplate}" 
    > 
    <telerikNavigation:RadWindow.Resources> 
        <localCommon:ExtConverter x:Key="StringToImageSourceConverter" /> 
        <DataTemplate x:Key="IconTemplate">  
            <Image Source="{Binding Converter={StaticResource StringToImageSourceConverter}}" /> 
        </DataTemplate> 
    </telerikNavigation:RadWindow.Resources> 

Maybe I don't understand it but the above wont work. I get the same error. How can I set the icontemplate directly?
0
Miroslav Nedyalkov
Telerik team
answered on 30 Dec 2009, 03:20 PM
Hi Gilbert,

 This code should fix work correctly:

<telerikNavigation:RadWindow 
    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
    xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
    xmlns:localCommon="clr-namespace:GaSuite"
    x:Class="GaSuite.Dep_EditWindow"
    Width="400" Height="Auto"
    mc:Ignorable="d"
    Icon="/Images/department.png"
    >
    <telerikNavigation:RadWindow.IconTemplate>
        <DataTemplate>
            <Image Source="{Binding Converter={StaticResource StringToImageSourceConverter}}" />
        </DataTemplate>
    </telerikNavigation:RadWindow.IconTemplate>
 
</telerikNavigation:RadWindow>
Hope this helps.

Kind regards,
Miroslav Nedyalkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Gilbert van Veen
Top achievements
Rank 1
answered on 30 Dec 2009, 03:29 PM
Miroslav,

You are a great!

It works fine now.

Thanks again.

Asked by
Gilbert van Veen
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Gilbert van Veen
Top achievements
Rank 1
Share this question
or