![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | How do I get to a TextBlock inside a Style I have defined the following style: <Style x:Key="EmployeeRequestCustomHeaderLabelArea" TargetType="{x:Type igDP:HeaderLabelArea}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:HeaderLabelArea}"> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <TextBlock TextAlignment="Center" Grid.Row="0" FontSize="16" FontStyle="Oblique" Foreground="White" Text="Are Awaiting Your Approval"></TextBlock> <ContentPresenter Grid.Row="1" Content="{TemplateBinding Content}"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> The style is used here: <igDP:XamDataPresenter x:Name="EmployeeRequestDataPresenter"> <igDP:XamDataPresenter.FieldLayoutSettings> <igDP:FieldLayoutSettings HeaderrLabelAreaStyle="{StaticResource EmployeeRequestCustomHeaderLabelArea}"/> </igDP:XamDataPresenter.FieldLayoutSettings> How can I programmatically change the Text property in the TextBlock? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How do I get to a TextBlock inside a Style Hi, Bruce Parker wrote: > I have defined the following style: > > <Style x:Key="EmployeeRequestCustomHeaderLabelArea" TargetType="{x:Type > igDP:HeaderLabelArea}"> > <Setter Property="Template"> > <Setter.Value> > <ControlTemplate TargetType="{x:Type igDP:HeaderLabelArea}"> > <Grid> > <Grid.RowDefinitions> > <RowDefinition /> > <RowDefinition /> > </Grid.RowDefinitions> > <TextBlock TextAlignment="Center" Grid.Row="0" FontSize="16" > FontStyle="Oblique" Foreground="White" Text="Are Awaiting Your > Approval"></TextBlock> > <ContentPresenter Grid.Row="1" Content="{TemplateBinding > Content}"/> > </Grid> > </ControlTemplate> > > </Setter.Value> > </Setter> > </Style> > > The style is used here: > > <igDP:XamDataPresenter x:Name="EmployeeRequestDataPresenter"> > <igDP:XamDataPresenter.FieldLayoutSettings> > > <igDP:FieldLayoutSettings > HeaderrLabelAreaStyle="{StaticResource > > EmployeeRequestCustomHeaderLabelArea}"/> > </igDP:XamDataPresenter.FieldLayoutSettings> > > > How can I programmatically change the Text property in the TextBlock? I'd say the easiest way is to set a Name on the TextBlock. Then you can use: TextBlock myText = bn.Template.FindName( "myTextBlock", bn ) as TextBlock; if ( myText != null ) { myText.Text = "World"; } Note: The VisualTree is not expanded yet in the Window's constructor, so you have to wait until the Loaded event is fired to access the Template's elements. HTH, Laurent -- Laurent Bugnion [MVP ASP.NET] Software engineering, Blog: http://www.galasoft-LB.ch PhotoAlbum: http://www.galasoft-LB.ch/pictures Support children in Calcutta: http://www.calcutta-espoir.ch |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Font Size - XP style vs Vista style | Vista General | |||
| Font Size - XP style vs Vista style | Vista General | |||
| Font Size - XP style vs Vista style | Vista General | |||