I have used the following code to associate a table value to a button. I would like to do a similar thing to with a textbox, but I keep getting a NullReferenceException.
<Telerik:GridViewCell Foreground="#FFFFFFFF" Width="80" ColumnName="submittal" TextBlock.FontSize="16" Margin="770,0,0,0" HorizontalAlignment="Left">
<Telerik:GridViewCell.Template>
<ControlTemplate>
<Button Click="Button_Click" Background="Transparent" Foreground="White" ClickMode="Press" Tag="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" AllowDrop="True" >
<TextBlock Width="75" Text="Submittal" />
</Button>
</ControlTemplate>
</Telerik:GridViewCell.Template>
</Telerik:GridViewCell>
What is wrong with:
<
Telerik:GridViewCell Foreground="#FFFFFFFF" Width="80" ColumnName="submittal" TextBlock.FontSize="16" Margin="770,0,0,0" HorizontalAlignment="Left">
<Telerik:GridViewCell.Template>
<ControlTemplate>
<TextBox Text="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" AllowDrop="True" >
</TextBox>
</ControlTemplate>
</Telerik:GridViewCell.Template>
</Telerik:GridViewCell>
?
{System.ArgumentNullException: Value cannot be null. |
Parameter name: reference |
at System.Windows.Media.VisualTreeHelper.GetDescendantBounds(Visual reference) |
at Telerik.Windows.Controls.UI.DragDropManager.IsMouseOverTarget(Visual target, GetPositionDelegate getPosition) |
at Telerik.Windows.Controls.UI.GridViewItemsControl.OnPreviewMouseUp(MouseButtonEventArgs e) |
at System.Windows.UIElement.OnPreviewMouseUpThunk(Object sender, MouseButtonEventArgs e) |
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) |
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) |
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) |
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) |
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) |
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) |
at System.Windows.Input.InputManager.ProcessStagingArea() |
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) |
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) |
<ControlTemplate x:Key="GridViewItemsControlTableTemplate" TargetType="{x:Type UI:GridViewItemsControl}"> |
<Grid Background="{TemplateBinding Background}"> |
<Grid.Resources> |
<UI:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter" /> |
</Grid.Resources> |
<Grid.RowDefinitions> |
<RowDefinition Height="Auto" /> |
<RowDefinition /> |
<RowDefinition x:Name="ScrollBarRow" MinHeight="10" |
Height="{Binding Source={StaticResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}, |
Converter={StaticResource DoubleToGridLengthConverter}}"/> |
</Grid.RowDefinitions> |
<Grid.ColumnDefinitions> |
<ColumnDefinition /> |
<ColumnDefinition x:Name="ScrollBarColumn" MinWidth="10" Width="{Binding Source={StaticResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}, Converter={StaticResource DoubleToGridLengthConverter}}"/> |
</Grid.ColumnDefinitions> |
<UI:GridViewBackground x:Name="PART_GridViewBackground" Margin="10,0,0,0" Grid.Row="0" |
Grid.ColumnSpan="1" Grid.RowSpan="2" |
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsHitTestVisible="False"/> |
<StackPanel Grid.Row="0"> |
<Border Margin="0,0,0,0" BorderThickness="0" ClipToBounds="True" |
Background="{StaticResource {x:Static Resources:FunctionalBrushes.EntityTabBackgroundBrushKey}}"> |
<UI:GridViewHeaderRow Name="PART_HeaderRow" VerticalAlignment="Top"/> |
</Border> |
<UI:GridViewNewRow Name="PART_AddNewRow" Margin="10,0,0,0" |
VerticalAlignment="Bottom" HorizontalAlignment="Stretch" |
Visibility="Collapsed" /> |
</StackPanel> |
<ScrollViewer Name="PART_ItemsScrollViewer" Focusable="False" VerticalScrollBarVisibility="Auto" |
HorizontalScrollBarVisibility="Auto" |
CanContentScroll="True" Grid.Row="1" Grid.RowSpan="2" Grid.ColumnSpan="2"> |
<ItemsPresenter Margin="10, 0, 0, 0"/> |
</ScrollViewer> |
</Grid> |
<ControlTemplate.Triggers> |
<Trigger Property="ComputedVerticalScrollBarVisibility" SourceName="PART_ItemsScrollViewer" Value="Collapsed"> |
<Setter Property="Width" TargetName="ScrollBarColumn" Value="10" /> |
</Trigger> |
<Trigger Property="ComputedHorizontalScrollBarVisibility" SourceName="PART_ItemsScrollViewer" Value="Collapsed"> |
<Setter Property="Height" TargetName="ScrollBarRow" Value="10" /> |
</Trigger> |
</ControlTemplate.Triggers> |
</ControlTemplate> |