tags:

views:

22

answers:

1

How to apply style in WPF Grid's first row at run time.

A: 

Just do this -

    Style style = new Style(typeof(RowDefinition));
    style.Setters.Add(new Setter(RowDefinition.HeightProperty, 10));

    yourGrid.RowDefinitions[0].Style = style;

Update:

You can use FrameworkElement.FindResource Method[ http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.findresource.aspx ] to find your style.

Check this for more details -

Resources and Code [ http://msdn.microsoft.com/en-us/library/ms752326.aspx ]

akjoshi
i have already defined a style in a "myTheame.xaml" so at runtime how to read style from "myTheame.xaml" and to apply it on grid's row.
Jeevan Bhatt
Updated Answer for this.
akjoshi