Welcome to the Xceed Community | Help
Community Search  
More Search Options

Does Xceed supports adding the styles dynamically for DataCell/ DataRow? If Yes then how?

Sort Posts: Previous Next
  •  08-20-2009, 8:53 AM Post no. 23424

    Does Xceed supports adding the styles dynamically for DataCell/ DataRow? If Yes then how?

    Hello,

    I had one query for you. I need to add the style, style triggers and Data Triggers dynamically and depending upon the database fields i needs to set the alignment in the grid not in xaml using the Data Triggers but using the style dynamically upon the datatype of the field. I tried using the styles dynamically but it didnt work. So can you please answer me whether xceed datarow/datacell supports the dynamically adding the styles.

     

    I am getting the desired output but for some DataCell i want the Alignment as Left which i may get using the Data Trigger but i am making the UserControl so i want to set it dynamically how could i get the desired output?

    I tried using the code in .cs as below in the Constructor:

    Style st = new Style(typeof(Xceed.Wpf.DataGrid.DataCell));

    st.Setters.Add(new Setter(HorizontalAlignmentProperty, "Right"));

    gd.Resources.Add("StyleForDataCell", st);

    The above code is not working.

    Kindly me send your inputs for the same.

    Thank You,

    Paras Sanghani


    Nothing Is Impossible
    Filed under:
  •  08-20-2009, 10:53 AM Post no. 23439 in reply to 23424

    Re: Does Xceed supports adding the styles dynamically for DataCell/ DataRow? If Yes then how?

     

    Hi Paras,

    To assign dynamically a Style on the grid whose targettype is DataCell in code behind you could write the following:

     

    gd.Resources[ typeof( DataCell ) ]=st;

    //where st is an implicit Style.

     


    Xceed - Software Developer and Technical Support
  •  08-21-2009, 1:56 AM Post no. 23449 in reply to 23439

    Re: Does Xceed supports adding the styles dynamically for DataCell/ DataRow? If Yes then how?

    Thank You.

     

     


    Nothing Is Impossible
  •  08-21-2009, 2:07 AM Post no. 23450 in reply to 23439

    Re: Does Xceed supports adding the styles dynamically for DataCell/ DataRow? If Yes then how?

    Thank alot Mohamed.

    Its worked well in the following way:

    Style st = new Style(typeof(Xceed.Wpf.DataGrid.DataCell));

                st.Setters.Add(new Setter(HorizontalContentAlignmentProperty, HorizontalAlignment.Right));

                this.Resources[typeof(DataCell)] = st;

     

    Thank a lot Again,

    Paras Sanghani


    Nothing Is Impossible
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.