2017-11-14 7 views
0

저는 DataGrid의 각 행에서 작업 할 수있는 툴팁을 얻으려고했습니다. 간단한 StackPanel과 일부 레이블을 사용하여 Tooltip 속성 안에 정보를 표시 할 수 있었지만 지금은 도구 설명으로 사용할보기를 삽입하려고했습니다.WPF (Caliburn.Micro)를 사용하여 XAML의 뷰 초기화

ciew를 표시 할 수 있었고 viewmodel이 작동하지만 맞춤 개체를 만들 수 없습니다 (AppointmentConfirmationNotification). 빈 개체 'ToolTipContent'를 사용할 수 있지만 아직 데이터 그리드에 바인딩하고 싶습니다.

여기 제가 현재 잘하고있는 코드입니다. 내 작업 Stackpanel '실험'에 대한 의견을 남겼습니다. 기본적으로 나는 어떻게 든 어딘가에 단순한 '{Binding}'어딘가에 삽입해야한다고 생각한다. 그러나 확실하지 않다.

<DataGrid.RowStyle> 
        <Style TargetType="DataGridRow"> 
         <Style.Resources> 
          <model:AppointmentConfirmationNotification x:Key="ToolTipContent"> 
          </model:AppointmentConfirmationNotification> 

         </Style.Resources> 
         <Setter Property="ToolTip"> 
          <Setter.Value > 
           <!-- 
           OLD STACKPANEL WORKING SAMPLE 
           <StackPanel> 
            <Grid> 
             <Grid.RowDefinitions> 
              <RowDefinition Height="*"></RowDefinition> 
             </Grid.RowDefinitions> 

             <WrapPanel Grid.Row="0"> 
              <Label>ID : </Label> 
              <Label Content="{Binding AppointmentConfirmation.AppointmentID}"/> 
             </WrapPanel> 

            </Grid> 
           </StackPanel> 
           --> 

           <v:APTooltipView> 
            <v:APTooltipView.DataContext> 
             <ObjectDataProvider ObjectType="{x:Type vm:APTooltipViewModel}"> 
              <ObjectDataProvider.ConstructorParameters> 
               <StaticResource ResourceKey="ToolTipContent"/> 
              </ObjectDataProvider.ConstructorParameters> 
             </ObjectDataProvider> 
            </v:APTooltipView.DataContext> 
           </v:APTooltipView> 
          </Setter.Value> 
         </Setter> 

         <Setter Property="TextElement.FontWeight" Value="{Binding Path=Read,Converter={StaticResource BooleanToFontweight}}"/> 
        </Style> 
       </DataGrid.RowStyle> 

나는 더 MVVM 접근 방식을 따르지만, 다른 접근 방법을 조언을 주시기 위해 XAML에서이 작업을 수행하기 위해 노력했다. 고마워요

답변

0

그냥 새로운보기를 만들고 DataContext를 전달할 수 있습니다. 당신은 당신이 좋아하는 것을 그 견해에 넣을 수 있습니다. 그것은 당신의 주요 관점에서 이렇게 보일 것입니다.

<StackPanel> 
    <local:"YOUR_VIEW" DataContext="{Binding AppointmentConfirmation, Mode=TwoWay}"/> 
</StackPanel> 

새로 만든보기는 다음과 같습니다. (DataContext에 존재하는 한) 원하는대로 추가하고 다른 목적으로이 뷰를 재사용 할 수 있습니다.

<UserControl x:Name="YOUR_VIEW" .... 
...... > 
    <Grid> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="*" /> 
    </Grid.RowDefinitions> 
    <WrapPanel Grid.Row="0"> 
     <Label>ID : </Label> 
     <Label Content="{Binding AppointmentID}"/> 
    </WrapPanel> 
    </Grid> 
</UserControl>