Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <UserControl x:Class="ClassLibrary1.UserControl1"
- xmlns:local="clr-namespace:ClassLibrary1"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
- <UserControl.Template>
- <ControlTemplate>
- <StackPanel>
- <Button Content="Custom Control Text Area 1" IsEnabled="{Binding IsEnabled}" />
- <ContentPresenter Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}"/>
- <TextBlock Text="Custom Control Text Area 2" />
- </StackPanel>
- </ControlTemplate>
- </UserControl.Template>
- namespace ClassLibrary1
- {
- public partial class UserControl1 : UserControl
- {
- public UserControl1()
- {
- InitializeComponent();
- }
- }
- }
- <StackPanel>
- <l:UserControl1>
- <StackPanel >
- <Button Click="Button_Click" Content="Click"/>
- <Button Content="My Control's Content" IsEnabled="{Binding Isbuttonenable}"/>
- </StackPanel>
- </l:UserControl1>
- </StackPanel>
- namespace ClassLibrary1
- {
- public partial class UserControl1 : UserControl
- {
- UserControl1ViewModel model = new UserControl1ViewModel();
- public UserControl1()
- {
- InitializeComponent();
- this.DataContext = model;
- }
- }
- }
- <StackPanel>
- <l:UserControl1 DataContext="{StaticResource MyUserControl1ViewModelInstance}">
- <StackPanel >
- <Button Click="Button_Click" Content="Click"/>
- <Button Content="My Control's Content" IsEnabled="{Binding Isbuttonenable}"/>
- </StackPanel>
- </l:UserControl1>
- </StackPanel>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement