Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Window x:Class="ChainedBindingUserControl.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="MainWindow"
- Height="350" Width="525"
- xmlns:Local="clr-namespace:ChainedBindingUserControl"
- >
- <StackPanel>
- <TextBlock Text="{Binding Data}"
- Width="150"
- />
- <ComboBox ItemsSource="{Binding Origin}"
- Width="150"
- />
- <Label Content="--------------------------------------------------"
- Width="200"
- />
- <Local:UserControl1 Liste="{Binding Origin}"
- Noun="{Binding Data}"
- Height="50" Width="150"
- />
- </StackPanel>
- </Window>
- namespace ChainedBindingUserControl
- {
- public partial class MainWindow : Window
- {
- public ObservableCollection<String> Origin
- {
- get { return (ObservableCollection<String>)GetValue(OriginProperty); }
- set { SetValue(OriginProperty, value); }
- }
- public static readonly DependencyProperty OriginProperty =
- DependencyProperty.Register("Origin", typeof(ObservableCollection<String>), typeof(MainWindow),
- new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
- public String Data
- {
- get { return (String)GetValue(DataProperty); }
- set { SetValue(DataProperty, value); }
- }
- public static readonly DependencyProperty DataProperty =
- DependencyProperty.Register("Data", typeof(String), typeof(UserControl1),
- new FrameworkPropertyMetadata("Blablabla", FrameworkPropertyMetadataOptions.AffectsRender));
- public MainWindow()
- {
- InitializeComponent();
- this.DataContext = this;
- ObservableCollection<String> zog = new ObservableCollection<String>();
- zog.Add("A");
- zog.Add("B");
- zog.Add("C");
- Origin = zog;
- }
- }
- }
- <UserControl x:Class="ChainedBindingUserControl.UserControl1"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- mc:Ignorable="d"
- Name="root"
- d:DesignHeight="300" d:DesignWidth="300">
- <StackPanel>
- <TextBlock Text="{Binding Noun}"
- />
- <ComboBox ItemsSource="{Binding Liste}"
- />
- </StackPanel>
- </UserControl>
- namespace ChainedBindingUserControl
- {
- public partial class UserControl1 : UserControl
- {
- public ObservableCollection<String> Liste
- {
- get { return (ObservableCollection<String>)GetValue(ListeProperty); }
- set { SetValue(ListeProperty, value); }
- }
- public static readonly DependencyProperty ListeProperty =
- DependencyProperty.Register("Liste", typeof(ObservableCollection<String>), typeof(UserControl1),
- new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
- public String Noun
- {
- get { return (String)GetValue(NounProperty); }
- set { SetValue(NounProperty, value); }
- }
- public static readonly DependencyProperty NounProperty =
- DependencyProperty.Register("Noun", typeof(String), typeof(UserControl1),
- new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
- public UserControl1()
- {
- InitializeComponent();
- this.DataContext = this;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement