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

a value of type 'style' cannot be added to a collection or dictionary of type 'uielementcollection'

$
0
0

Hi,

I'm new to WPF, Can someone tell me how to align my datagrid cell text in center.  

Currently am using

Windows 8 64-bit operating system

Microsoft Visual Studio 2012 

Microsoft .NET Framework Version 4.5 

I tried solving using few codes by googling but i failed. One of the code is pasted below,

                            

   <Style x:Key="RightCellStyle" TargetType="{x:Type Custom:DataGridCell}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Custom:DataGridCell}">
                        <Grid Background="{TemplateBinding Background}">
                            <ContentPresenter HorizontalAlignment="Right" VerticalAlignment="Center"/>

                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

Am getting an error saying as mentioned below,

a value of type 'Style' cannot be added to a collection or dictionary of type 'uielementcollection' 

a value of type 'Setter' cannot be added to a collection or dictionary of type 'uielementcollection' 

a value of type 'ControlTemplate' cannot be added to a collection or dictionary of type 'uielementcollection' 



Viewing all articles
Browse latest Browse all 18858

Trending Articles



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