Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. <UserControl x:Class="ClassLibrary1.UserControl1"
  2. xmlns:local="clr-namespace:ClassLibrary1"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  5. <UserControl.Template>
  6. <ControlTemplate>
  7. <StackPanel>
  8. <Button Content="Custom Control Text Area 1" IsEnabled="{Binding IsEnabled}" />
  9. <ContentPresenter Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}"/>
  10. <TextBlock Text="Custom Control Text Area 2" />
  11. </StackPanel>
  12. </ControlTemplate>
  13. </UserControl.Template>
  14.  
  15. namespace ClassLibrary1
  16. {
  17. public partial class UserControl1 : UserControl
  18. {
  19. public UserControl1()
  20. {
  21. InitializeComponent();
  22. }
  23. }
  24. }
  25.  
  26. <StackPanel>
  27. <l:UserControl1>
  28. <StackPanel >
  29. <Button Click="Button_Click" Content="Click"/>
  30. <Button Content="My Control's Content" IsEnabled="{Binding Isbuttonenable}"/>
  31. </StackPanel>
  32. </l:UserControl1>
  33.  
  34. </StackPanel>
  35.  
  36. namespace ClassLibrary1
  37. {
  38. public partial class UserControl1 : UserControl
  39. {
  40. UserControl1ViewModel model = new UserControl1ViewModel();
  41. public UserControl1()
  42. {
  43. InitializeComponent();
  44. this.DataContext = model;
  45. }
  46. }
  47. }
  48.  
  49. <StackPanel>
  50. <l:UserControl1 DataContext="{StaticResource MyUserControl1ViewModelInstance}">
  51. <StackPanel >
  52. <Button Click="Button_Click" Content="Click"/>
  53. <Button Content="My Control's Content" IsEnabled="{Binding Isbuttonenable}"/>
  54. </StackPanel>
  55. </l:UserControl1>
  56.  
  57. </StackPanel>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement