首页 文章

在silverlight中的网格中的文本框中添加工具提示

提问于
浏览
-1
<Grid>
<Canvas>

<TextBox Name="txt" IsReadOnly="True" Width="620" VerticalAlignment="Center"
Canvas.Left="340" Canvas.Top="5" Text="{Binding RowTitle2,Mode=OneWay}"    
ToolTipService.ToolTip="{Binding Path=Text, RelativeSource={RelativeSource Self}}"
TextWrapping="NoWrap" HorizontalAlignment="Stretch"/>

</Canvas>
</Grid>

这种方式没有工具提示,那么如何添加?在这里我创建动态记录(网格中的txtboxes)

但是在类似的例子中一切正常(没有动态创建txtbox)

<Grid>
<Canvas>

  <TextBox Name="txt" Margin="0,5,5,0" IsReadOnly="True" Width="620" VerticalAlignment="Center"
  Canvas.Left="-200" Canvas.Top="-5" 
ToolTipService.ToolTip="{Binding Path=Text, RelativeSource={RelativeSource Self}}"
TextWrapping="NoWrap" HorizontalAlignment="Stretch"/>

</Canvas>
</Grid>

1 回答

  • 0

    这有什么意义?在位于网格中的画布中使用ReadOnly文本框有点令人困惑 . 而是使用TextBlock,它还可以提高性能,防止内存泄漏,并且看起来更好 .

    <Grid>
      <TextBlock Margin="0,5,5,0" 
    VerticalAlignment="Center" 
    HorizontalAlignment="Stretch"
    TextWrapping="NoWrap"
    Text="{Binding RowTitle2}"
    ToolTipService.ToolTip="{Binding Path=Text, RelativeSource={RelativeSource Self}}"
     />
    </Grid>
    

相关问题