Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Formatting an element contained in another control
Message
De
08/03/2008 16:50:25
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Titre:
Formatting an element contained in another control
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01300068
Message ID:
01300068
Vues:
51
Still feeling brain dead on XAML :(

Simple control:
<UserControl x:Class="cdsThemes.TestControl2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="300" Width="300">
    <Grid Background="BlanchedAlmond">
  <TextBox Height="23" 
             Margin="25,103,0,0" 
             Name="textBox1" 
             VerticalAlignment="Top" 
             HorizontalAlignment="Left" 
             Width="120">Blah Blah Blah</TextBox>
  </Grid>
</UserControl>
And I use it in another simple control:
<UserControl x:Class="cdsThemes.TestControl1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:cdsThemes"
    Height="300" Width="300">
    <Grid>
    <local:TestControl2 x:Name="testControl2"></local:TestControl2>
  </Grid>
</UserControl>
Lets say I want to change the margin on textBox1 inside of TestControl2 from the XAML in TestControl1. How do I do that?

My actual situation may be harder because textBox1 in that case is a custom control based on a TextBox defined in another assembly. But I can't even get this one to work, so I figured I'd start with the simpler problem.

I can do it easy in C#
testControl2.textBox1.Margin = new Thickness(1, 1, 1, 1);
just can't seem to work out the XAML.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform