Put a complete Grid into a Resource

1 posts, 0 answers
  1. Harald Bacik
    Harald Bacik avatar
    13 posts
    Member since:
    Aug 2009

    Posted 09 Oct 2011 Link to this post

    Hey
    I am a newbie in Silverlight. I try to add a "complete" Grid into a Resource, so that I can reuse it over and over.
    But I always get an error, when I try to run my project. The error:
    An object of the type "Telerik.Windows.Controls.RadGridView" cannot be applied to a property that expects the type "System.Windows.Controls.ControlTemplate"

    <ResourceDictionary
        xmlns:local="clr-namespace:VisualOPTSL.myClasses">
     
        <!--Klassendefinition-->
     
        <local:ConvertDate x:Key="ConvertDate"/>
         
        <telerik:RadGridView x:Name="resCustomerGrid">
            <telerik:RadGridView.Columns>
                <telerik:GridViewToggleRowDetailsColumn />
                <telerik:GridViewComboBoxColumn Header="Firma" TextAlignment="Left"
                                                        DataMemberBinding="{Binding Firmenid}"
                                                        SelectedValueMemberPath="ID">
                    <telerik:GridViewComboBoxColumn.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Strasse}"/>
                                <TextBlock Text=", ("/>
                                <TextBlock Text="{Binding PLZ}"/>
                                <TextBlock Text=" "/>
                                <TextBlock Text="{Binding Ort}"/>
                                <TextBlock Text=") "/>
                            </StackPanel>
                        </DataTemplate>
                    </telerik:GridViewComboBoxColumn.ItemTemplate>
                </telerik:GridViewComboBoxColumn>
                <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding Anrede}" UniqueName="myAnrede" SelectedValueMemberPath="Id" DisplayMemberPath="Beschreibung"  />
                <telerik:GridViewDataColumn Header="KundenID" DataMemberBinding="{Binding KundenID}" IsVisible="True"/>
                <telerik:GridViewDataColumn Header="Titel" TextAlignment="Left" DataMemberBinding="{Binding Titel}"/>
                <telerik:GridViewDataColumn Header="Vorname" TextAlignment="Left" DataMemberBinding="{Binding VName}"/>
                <telerik:GridViewDataColumn Header="Nachname" TextAlignment="Left" DataMemberBinding="{Binding NName}"/>
                <telerik:GridViewDataColumn Header="Strasse" TextAlignment="Left" DataMemberBinding="{Binding Strasse}"/>
                <telerik:GridViewDataColumn Header="PLZ" TextAlignment="Right" DataMemberBinding="{Binding PLZ}"/>
                <telerik:GridViewDataColumn Header="Ort" TextAlignment="Left" DataMemberBinding="{Binding Ort}"/>
                <telerik:GridViewDataColumn Header="Vers.Nr" TextAlignment="Right" DataMemberBinding="{Binding VersNr}"/>
                <telerik:GridViewDataColumn Header="Geb. Datum" TextAlignment="Right" DataMemberBinding="{Binding GebDat}">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding GebDat, Converter={StaticResource ConvertDate}}" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
            <telerik:RadGridView.RowDetailsTemplate>
                <DataTemplate>
                    <telerik:RadTabControl x:Name="RadTabControl" Width="Auto" HorizontalAlignment="Left"
                                                   Margin="8" VerticalAlignment="Center"
                                                   DataContext="{Binding}" MinWidth="300">
                        <telerik:RadTabItem Header="Allgemeine Daten" Margin="10,0,0,0" Height="24">
                            <Grid Width="Auto" HorizontalAlignment="Stretch">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition Height="15" />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
     
     
                                <TextBlock Text="E-M@il: " Margin="5,10,0,0" Foreground="Black" FontWeight="Bold" Grid.Row="0" Grid.Column="1"  />
                                <TextBlock Text="{Binding EMail}" Margin="5,10,0,0" Foreground="Black" Grid.Row="0" Grid.Column="2"  />
                                <TextBlock Text="Telefon: " Margin="5,0,0,0" Foreground="Black" FontWeight="Bold" Grid.Row="1" Grid.Column="1"  />
                                <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="2">
                                    <TextBlock Text="{Binding VwFest}" Foreground="Black" Margin="5,0,0,0"  />
                                    <TextBlock Text="/"  Foreground="Black"/>
                                    <TextBlock Text="{Binding NummerFest}"  Foreground="Black"/>
                                    <TextBlock Text=" "  Foreground="Black"/>
                                </StackPanel>
                                <TextBlock Text="Mobiltelefon: " Margin="5,0,0,0" Foreground="Black" FontWeight="Bold" Grid.Row="2" Grid.Column="1"  />
                                <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="2">
                                    <TextBlock Text="{Binding VwMobil}" Foreground="Black" Margin="5,0,0,0"  />
                                    <TextBlock Text="/"  Foreground="Black"/>
                                    <TextBlock Text="{Binding NummerMobil}"  Foreground="Black"/>
                                    <TextBlock Text=" "  Foreground="Black"/>
                                </StackPanel>
                                <TextBlock Text="Anschrift: " Foreground="Black" Margin="5,0,0,0" FontWeight="Bold" Grid.Row="3" Grid.Column="1"  />
                                <StackPanel Orientation="Vertical" Grid.Row="3" Grid.Column="2">
                                    <TextBlock Text="{Binding Strasse}" Foreground="Black" Margin="5,0,0,0" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding PLZ}" Foreground="Black" Margin="5,0,0,0"  />
                                        <TextBlock Text=" "  Foreground="Black"/>
                                        <TextBlock Text="{Binding Ort}"  Foreground="Black"/>
                                        <TextBlock Text=" "  Foreground="Black"/>
                                    </StackPanel>
                                </StackPanel>
                                <TextBlock Text="Versicherungsgruppe: " Margin="5,0,0,0" Foreground="Black" FontWeight="Bold" Grid.Row="4" Grid.Column="1"  />
                                <telerik:RadComboBox  x:Name="radInsuranceGroup"
                                                             SelectedValue="{Binding VersGruppe}" 
                                                             DisplayMemberPath="Beschreibung"
                                                             SelectedValuePath="ID"
                                                             Margin="5,5,5,5"
                                                             Grid.Row="4"
                                                             Grid.Column="2"  />
                                <CheckBox Content="Selbstbehalt " Grid.Column="2" IsChecked="{Binding Selbstbehalt}" Margin="5,0,0,0" Foreground="Black" Grid.Row="5" />
     
                            </Grid>
                        </telerik:RadTabItem>
                    </telerik:RadTabControl>
                </DataTemplate>
            </telerik:RadGridView.RowDetailsTemplate>
        </telerik:RadGridView>
     
    </ResourceDictionary>

    So please, could someone please tell me how I can get this resolved?

    THX
Back to Top