Microsoft MVP성태의 닷넷 이야기
안녕하세요. 질문이 있습니다. [링크 복사], [링크+제목 복사],
조회: 21102
글쓴 사람
POCO
홈페이지
첨부 파일
 

wpf에서 유저컨트롤을 만들고 바인딩을 거는데 궁금점이 있어서 질문 드립니다.

<UserControl x:Class="MyTest.Cell"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="90" d:DesignWidth="100" Name="Cell">

<TextBlock x:Name="tb_Age" Text="{Binding Age}" />

</UserControl>


cs코드
public static readonly DependencyProperty AgeProperty =
            DependencyProperty.Register("Age", typeof(string), typeof(UserControl), new PropertyMetadata(null));
public string Age
{
            get { return (string)GetValue(AgeProperty); }
            set { SetValue(AgeProperty, value); }
}


위 처럼 했을 경우 바인딩할 수 없는데 당연히 DataContext가 지정되지 않아서 바인딩이 안된다고 이해하고 있습니다.

하지만 xaml에서 바인딩에 ,ElementName=Cell를 추가해 주면 바인딩이 됩니다.

ElementName에 Cell은 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 이 부분인데 이 부분 하나추가로써 어떻게 바인딩이 이루어 졌는지 궁금합니다.

답변부탁드립니다.








[최초 등록일: ]
[최종 수정일: 3/6/2014]


비밀번호

댓글 작성자
 



2014-03-06 10시02분
제가 질문을 잘못 이해하고 있는지도 모르겠는데요. ElementName의 "Cell"은 UserControl 열림 태그의 마지막에 Name="Cell"로 지정되어서 가능한 것입니다.
정성태

1  2  [3]  4  5  6  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
5921한예지 donator10/3/202315197마샬링 정의 및 목적이 궁금합니다. [5]
5920한예지 donator10/3/202314885C#과 WIN32 API 관계 질문드립니다. [4]
5919이건우9/27/202313552WinForm의 로딩속도 관련 질문입니다 [2]
5917한예지 donator9/14/202314094동기화 도구 질문 있습니다. [4]
5916한예지 donator9/3/202314559Thread.Sleep(500), await Task.Delay(500), Task.Delay(500) 차이점이 궁금합니다. [2]
5915한예지 donator8/30/202316337비동기 코드를 for 문 안에 작성한 경우 제어 변수가 올바르게 동작하지 않는 이유가 궁금합니다. [3]
5914한상욱8/11/202315640.net wpf에서 skiasharp 의 skelement 를 canvas로 사용 하고 있습니다. [1]
5913김태우8/10/202315191지역변수로 이해하는 메서드매개변수 게시글 댓글 [3]
5912guest4/25/202321981[참고 - 초보용] Sqlite 디비는 double이 없고 Real이 대신합니다 [3]
5911guest4/24/202313997Form1.cs와 외부 class.cs와 통신 (static async method포함) [4]파일 다운로드1
5910guest4/24/202313388Async 메서드와 try~catch [1]
5909guest4/22/202315166Visual Studio 구매 시(1인 개발자) [4]
5908guest4/22/202314400텅빈 원그리기 [5]
5907민성4/21/202314435안녕하세요 서버 백업 문제에 대해서 [2]
5906guest4/21/202314761Dispatcher 서비스 구현 질문 [1]
5905guest4/20/202315732tabControl의 tabPage가 여러 개일 때 순서를 바꾸기가 까다롭네요 [5]
5904guest4/18/202316243[신규자료첨부] DLL 'SQLite.Interop.dll'을 찾을 수 없습니다 [4]파일 다운로드1
5903guest4/18/202314862fileSystemWatcher 이벤트 관련 질문입니다 [2]
5902guest4/17/202315841c#으로 USB 관련 질문 [2]
5901guest4/17/202312758내솔루션 판매 시 1.0.0.0 폴더와 Sqlite 배포 [5]
5900guest4/17/202316451DLL 'SQLite.Interop.dll'을 찾을 수 없습니다 [2]파일 다운로드1
5899guest4/17/202314003Dictionary와 Linq [4]
5898차가워4/17/202313438CNTK 교육 문의 [1]
5897guest4/17/202313043Socket스레드와 UI thread [4]
5896HAN4/16/202313346c언어 return 에 대해 궁금한게 있어요. [1]파일 다운로드1
5895guest4/15/202313635Drag and Drop - 모든 컨트롤 [2]
1  2  [3]  4  5  6  7  8  9  10  11  12  13  14  15  ...