Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. Binding Mutiple Child Window Controls to Window Dependency Property [modified]

Binding Mutiple Child Window Controls to Window Dependency Property [modified]

Scheduled Pinned Locked Moved WCF and WF
wpfquestionwcfcom
2 Posts 1 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RNEELY
    wrote on last edited by
    #1

    Given a dependecy property "Val": public partial class Window3 : Window { public Window3() { InitializeComponent(); } public static readonly DependencyProperty ValProperty = DependencyProperty.Register("Val", typeof(float), typeof(Window3), new FrameworkPropertyMetadata((float)50.0)); public float Val { get { return (float)GetValue(ValProperty); } set { SetValue(ValProperty, value); } } } How can I bind multiple child controls to it? Following does not work: <Window x:Class="ZoomTest.Window3" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window3" Height="300" Width="300"> <StackPanel> <ProgressBar x:Name="Progress" Value="{Binding Path=Val, ElementName=Window3, Mode=Default}"/> <Slider x:Name="MySlider" Value="{Binding Path=Val, ElementName=Window3, Mode=Default}" Minimum="{Binding Path=Minimum, ElementName=Progress, Mode=Default}" Maximum="{Binding Path=Maximum, ElementName=Progress, Mode=Default}"/> </StackPanel> </Window>

    Sincerely, -Ron

    modified on Thursday, April 17, 2008 6:04 PM

    R 1 Reply Last reply
    0
    • R RNEELY

      Given a dependecy property "Val": public partial class Window3 : Window { public Window3() { InitializeComponent(); } public static readonly DependencyProperty ValProperty = DependencyProperty.Register("Val", typeof(float), typeof(Window3), new FrameworkPropertyMetadata((float)50.0)); public float Val { get { return (float)GetValue(ValProperty); } set { SetValue(ValProperty, value); } } } How can I bind multiple child controls to it? Following does not work: <Window x:Class="ZoomTest.Window3" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window3" Height="300" Width="300"> <StackPanel> <ProgressBar x:Name="Progress" Value="{Binding Path=Val, ElementName=Window3, Mode=Default}"/> <Slider x:Name="MySlider" Value="{Binding Path=Val, ElementName=Window3, Mode=Default}" Minimum="{Binding Path=Minimum, ElementName=Progress, Mode=Default}" Maximum="{Binding Path=Maximum, ElementName=Progress, Mode=Default}"/> </StackPanel> </Window>

      Sincerely, -Ron

      modified on Thursday, April 17, 2008 6:04 PM

      R Offline
      R Offline
      RNEELY
      wrote on last edited by
      #2

      Ok. This works. <Window x:Class="ZoomTest.Window3" x:Name="Me" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window3" Height="300" Width="300"> <StackPanel> <ProgressBar x:Name="Progress" Value="{Binding Path=Val, ElementName=Me, Mode=Default}"/> <Slider x:Name="MySlider" Value="{Binding Path=Val, ElementName=Me, Mode=Default}" Minimum="{Binding Path=Minimum, ElementName=Progress, Mode=Default}" Maximum="{Binding Path=Maximum, ElementName=Progress, Mode=Default}"/> </StackPanel> </Window> But I hate Me. It reminds me of VB. Ideally this would be more concise but doesn't work: <Window x:Class="ZoomTest.Window3" x:Name="Me" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window3" Height="300" Width="300"> <StackPanel> <ProgressBar x:Name="Progress" Value="{Binding Path=Val}"/> <Slider x:Name="MySlider" Value="{Binding Path=Val}" Minimum="{Binding Path=Minimum, ElementName=Progress}" Maximum="{Binding Path=Maximum, ElementName=Progress}"/> </StackPanel> </Window> Is there any way to set the default data context to the window for all of it's children?

      Sincerely, -Ron

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups