Answered Clipping with binding

  • Friday, May 12, 2006 10:26 AM
     
     

    Hi all,

    I would like to clip everything which is the border.

    <Border BorderBrush="#FF646464" BorderThickness="2,2,2,2" CornerRadius="5" ClipToBounds="True">

    <DockPanel x:Name="Frame" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Grid DockPanel.Dock="Left">

    <Grid.Clip>

    <RectangleGeometry RadiusX="5" RadiusY="5" Rect="0,0,100,25"></RectangleGeometry>

    </Grid.Clip>

    <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding ElementName=Text, Path=ActualWidth}" Height="{Binding ElementName=Text, Path=ActualHeight}">

    <Rectangle.Fill>

    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">

    <LinearGradientBrush.GradientStops>

    <GradientStop Offset="0" Color="#FFFCF4C7" />

    <GradientStop Offset="0.4" Color="#FFFCF4C7" />

    <GradientStop Offset="0.6" Color="#FFEFE292" />

    <GradientStop Offset="1" Color="#FFEFE292" />

    </LinearGradientBrush.GradientStops>

    </LinearGradientBrush>

    </Rectangle.Fill>

    </Rectangle>

    <TextBlock x:Name="Text" Padding="10,3,10,3" Text="{TemplateBinding Property=Content}" HorizontalAlignment="Center" VerticalAlignment="Center" />

    </Grid>

    </DockPanel>

    </Border>

    Is there a way to bind the width and the height of the clipping rect to the width or the height of the Grid or better the Border above?

     

    I've tried this, but after this a won't see anything exept the border.

    <Border x:Name="Frame" BorderBrush="#FF646464" BorderThickness="2,2,2,2" CornerRadius="5" ClipToBounds="True">

    <DockPanel x:Name="Frame" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Grid DockPanel.Dock="Left">

    <Grid.Clip>

    <RectangleGeometry RadiusX="5" RadiusY="5" Rect="{Binding ElementName=Frame, Path=RenderSize}"></RectangleGeometry>

    </Grid.Clip>

All Replies

  • Monday, May 15, 2006 7:58 AM
     
     

     

  • Monday, May 15, 2006 8:11 AM
     
     
    I don't think that you need to write like this...

    Don't forget that XAML is a new technology, and nobody (except some Microsoft guys) is expert on it.

    So, if no one give you a response, maybe it's because no one knows it ;)


    Bye
  • Tuesday, May 16, 2006 7:27 AM
     
     

    Ok, At least that was an answer :-)

    I thought that guys from microsoft are in this forum, so it's very important for us to get an answer if this is possible or not?

  • Monday, July 10, 2006 6:19 PM
     
     Answered

    Hi,

    sorry about the delay -- I was pinging around the group and it seems that you can only do this with writing a bit of code. Unfortunately, our property system cannot set a binding to Rect's properties as those are not DependencyProperties.

    So you can write a MultiBinding for converting both Height and Width together, and you will need to implement IMultiValueConverter. In your implementation, you would want to take in two doubles and output the corresponding Rect.

    -Seema