Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Having a celltemplate inside a datagridcolumn with static resources converter and events is throwing Null ref exception.

$
0
0

Hi,

I am generating a GridColumn within a DataTemplate("MyCellTemplate") as follows.

<DataTemplate x:Key="MyCellTemplate"><ContentControl><dxg:GridColumn FieldName="{Binding ColumnIdentifier}"

Header="{Binding DisplayText}" Width="50" AllowColumnFiltering="False" UnboundType="Boolean"><dxg:GridColumn.CellTemplate><DataTemplate><ToggleButton IsChecked="{Binding Value,Converter={StaticResource ShortToBooleanConverter}, Mode=TwoWay}" Checked="ToggleButton_Checked_Changed" Unchecked="ToggleButton_Checked_Changed"><ToggleButton.Template><ControlTemplate TargetType="ToggleButton"><Border Name="border" Background="LightGray" /><ControlTemplate.Triggers><Trigger Property="IsChecked" Value="True"><Setter Property="Background" Value="Green" TargetName="border" /></Trigger></ControlTemplate.Triggers></ControlTemplate></ToggleButton.Template></ToggleButton><!--<TextBlock Text="{Binding Value}" FontSize="8" Background="LightGray"/>--></DataTemplate></dxg:GridColumn.CellTemplate></dxg:GridColumn></ContentControl></DataTemplate>

Issue is when i use the converter: "ShortToBooleanConverter" it throws NullReference exception at:

System.Windows.Markup.IStyleConnector.Connect(Int32 connectionId, Object target) .

I researched online and found that there is some bug with .NET 4.0 when there is a combination of static resource and event handler with in a template. So please suggest why i get this error and what is the solution for it.

 


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>