XAML
<Window x:Class="Ahihi.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Ahihi" Height="300" Width="300"
>
<Grid>
<Canvas Name="Mega"></Canvas>
</Grid>
</Window>
C# code
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
namespace Ahihi
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
Mega.Children.Add(new Border(){Name="linh"});
((Border)(Mega.FindName("linh"))).Background=Brushes.Red;
}
}
}
Em không hiểu tại sao mà đoạn code ((Border)(Mega.FindName("linh")))
nó return NULL? Em loay hoay mãi mà không được T_T. Mấy bác giúp em với!