Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to set component TextBlock Text from code, I try to access it like
C#
this.lbTitle.Text
but this cant access from code..

XML
<Window.Resources>
        <Style x:Key="ButtonOpacity" TargetType="{x:Type Button}">
            <Setter Property="Control.Opacity" Value="0.2"></Setter>
        </Style>
        <Dialog:CustomDialog x:Key="CustomDialogTest"
                                 x:Name="CustomTestDialog">

            <Grid Background="Beige" ShowGridLines="False">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto"  />
                </Grid.RowDefinitions>
                <Image Height="250" Source="/images/rumus.jpg" Grid.Column="0" Grid.Row="0" Grid.RowSpan="12" Margin="10,10,10,10" />
                <TextBlock Grid.Column="1" Grid.Row="0" FontSize="20" Text="Title:" />
                <TextBlock x:Name="lbTitle" Grid.Column="2" Grid.Row="0" FontSize="20" Text="" />

            </Grid>
        </Dialog:CustomDialog>
    </Window.Resources>
Posted
Comments
Herman<T>.Instance 18-Nov-14 9:09am    
tried this example here?
payjo 18-Nov-14 9:15am    
the problem is my component inside window.resources,
set text like lbTitle.Text = "Hello World" is not allowed, I think use data binding, but I still no understand to use data binding in wpf.
johannesnestler 18-Nov-14 9:47am    
OMG: Not understand databinding when using wpf but want to use a Dialog as resource. Sorry this is no offense - but one day with a WPF tutorial would help much more than posting questions about doing it wrong...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900