コード例 #1
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            // Silverlight workaround
            // LayoutRoot
            // MaxHeight="{Binding Path=ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ScrollViewer}}}"
            DependencyObject obj = this;

            while (obj != null)
            {
                if (obj is ScrollViewer)
                {
                    break;
                }
                obj = VisualTreeHelper.GetParent(obj);
            }
            if (obj != null)
            {
                ActualSizePropertyProxy proxy = new ActualSizePropertyProxy();
                proxy.Element = (FrameworkElement)obj;
                LayoutRoot.SetBinding(Grid.MaxHeightProperty, new Binding()
                {
                    Mode   = BindingMode.OneWay,
                    Path   = new PropertyPath("ActualHeightValue"),
                    Source = proxy,
                });
            }
        }
コード例 #2
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     // Silverlight workaround
     // LayoutRoot
     // MaxHeight="{Binding Path=ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ScrollViewer}}}"
     DependencyObject obj = this;
     while (obj != null)
     {
         if (obj is ScrollViewer)
         {
             break;
         }
         obj = VisualTreeHelper.GetParent(obj);
     }
     if (obj != null)
     {
         ActualSizePropertyProxy proxy = new ActualSizePropertyProxy();
         proxy.Element = (FrameworkElement)obj;
         LayoutRoot.SetBinding(Grid.MaxHeightProperty, new Binding()
         {
             Mode = BindingMode.OneWay,
             Path = new PropertyPath("ActualHeightValue"),
             Source = proxy,
         });
     }
 }