Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
340
Applying styles to fields not working
posted

I have columns in a grid that is bound to a dataset.  In my code I am applying styles to the fields that the api added dynamically based on the dataset.  This doesn't work.

 

public

 

 

partial class VegaView : UserControl

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

{

 

 

 

public

VegaView()

{

InitializeComponent();

 

 

 

this.Loaded += new RoutedEventHandler

(VegaView_Loaded);

 

}

 

 

 

void VegaView_Loaded(object sender, RoutedEventArgs

e)

{

initializeGrid(

 

 

this

.grdStrikes);

}

 

 

 

private void initializeGrid(XamDataGrid

dataGrid)

{

 

 

 

var

layout = dataGrid.FieldLayouts[0];

dataGrid.FieldLayouts[0].Settings.SelectionTypeCell =

 

 

SelectionType

.Range;

dataGrid.FieldLayouts[0].Settings.SelectionTypeField =

 

 

SelectionType

.Range;

dataGrid.FieldLayouts[0].Settings.SelectionTypeRecord =

 

 

SelectionType

.None;

 

 

 

 

bool stepsColumn = true

;

 

 

 

foreach (var field in

dataGrid.FieldLayouts[0].Fields)

{

field.Settings.AllowEdit =

 

 

false

;

field.Settings.LabelPresenterStyle = (

 

 

Style)this.Resources["LabelPresenterStyle"

];

 

 

 

if

(stepsColumn)

{

field.Settings.EditorStyle = (

 

 

Style)this.Resources["StepsStyle"

];

}

stepsColumn =

 

 

false

;

Parents
No Data
Reply
  • 138253
    Offline posted

    Hello Kayode,

     

    It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking into your post and I created a sample project for you and I used the code you have provided and everything seems to work ok on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.

     

    Feel free to write me if you have further questions.

    WpfApplication1.zip
Children
No Data