WPF NameScopes

There are 1 entries for the tag WPF NameScopes
WPF Namescopes

Questo frammento di XAML non compila: <StackPanel> <Button Width="100" Height="50" x:Name="btn1" Content="B1" /> <Button Width="100" Height="50" x:Name="btn1" Content="B2" /> </StackPanel> il motivo è evidente: Non è possibile avere due elementi con lo stesso nome nel LogicalTree, proviamo quindi con questa alternativa: <StackPanel x:Name="sp1"> <Button Width="100" Height="50" x:Name="btn1" Content="B1" Click="button1_Click" /> </StackPanel> private void button1_Click(object sender, RoutedEventArgs e) { Button btn1 = new Button() { Name = "btn1", Width = 100, Height = 50, Content="B1" }; sp1.Children.Add(btn1); } e in questo caso...

posted @ venerdì 9 gennaio 2009 10:04 | Feedback (2)