Guest User

How to bind color to textbox background wpf

a guest
Feb 21st, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <TextBlock Width="Auto" Height="Auto"
  2. Text="{Binding ConnectionType}"
  3. Canvas.Left="{Binding LabelPosition.X}"
  4. Canvas.Top="{Binding LabelPosition.Y}" Background="{Binding ParentCanvasColor}">
  5.  
  6. <TextBlock.RenderTransform>
  7. <TranslateTransform X="5" Y="5"/>
  8. </TextBlock.RenderTransform>
  9. </TextBlock>
  10.  
  11. public Color ParentCanvasColor
  12. {
  13. get
  14. {
  15. if (parentCanvas != null && parentCanvas is DesignerCanvasNetDiag)
  16. {
  17. return Colors.Red;
  18. }
  19. return Colors.Transparent;
  20. }
  21. }
  22.  
  23. public SolidColorBrush ParentCanvasColor
  24. {
  25. get
  26. {
  27. if (parentCanvas != null && parentCanvas is DesignerCanvasNetDiag)
  28. {
  29. return new SolidColorBrush(Colors.Red);
  30. }
  31. return new SolidColorBrush(Colors.Transparent);
  32. }
  33. }
Add Comment
Please, Sign In to add comment