Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Binding OnwayToSource not working as expected - what alternatives?
- <DataTemplate DataType="{x:Type p:Fish}">
- <Border BorderBrush="Black" BorderThickness="2" >
- <TextBlock FontSize="14" TextAlignment="Center" VerticalAlignment="Center"
- Width="{Binding Path=width, Mode=OneWayToSource}"
- Height="{Binding Path=height, Mode=OneWayToSource}" ...
- class Fish {
- public double width { get; set; } // From DataTemplate TextBlock.Width.
- public double height { get; set; } // From DataTemplate TextBlock.Height
- }
- ...
- double rendered_width = my_fish.width; // Use the rendered width!
- <TextBlock ...
- SizeObserver.Observe="True"
- SizeObserver.ObservedWidth="{Binding Width, Mode=OneWayToSource}"
- SizeObserver.ObservedHeight="{Binding Height, Mode=OneWayToSource}"
- <StackPanel Orientation="Vertical">
- <Border BorderThickness="1" BorderBrush="Red">
- <TextBlock Name="tbwidthA" Text="{Binding Path=Howdy}" HorizontalAlignment="Left" Width="200"/>
- </Border>
- <TextBlock Name="tbwidthAw" Text="{Binding ElementName=tbwidthA, Path=Width}" HorizontalAlignment="Left"/>
- <TextBlock Name="tbwidthAaw" Text="{Binding ElementName=tbwidthA, Path=ActualWidth}" HorizontalAlignment="Left" />
- <Border BorderThickness="1" BorderBrush="Red">
- <TextBlock Name="tbwidthB" Text="{Binding Path=Howdy}" HorizontalAlignment="Left" />
- </Border>
- <TextBlock Name="tbwidthBw" Text="{Binding ElementName=tbwidthB, Path=Width}" HorizontalAlignment="Left" />
- <TextBlock Name="tbwidthAbw" Text="{Binding ElementName=tbwidthB, Path=ActualWidth}" HorizontalAlignment="Left" />
- <Button Content="TBwidth" Click="Button_Click_1" Width="60" HorizontalAlignment="Left" />
- </StackPanel>
- Debug.WriteLine(tbwidthB.Width.ToString());
- Debug.WriteLine(tbwidthB.ActualWidth.ToString());
Add Comment
Please, Sign In to add comment