I made incorrect assumption that setting IsOpen to true would show the box and setting the property to false would close it. Is there a way to close the infoBox via binding?
Hi,
Your assumption was correct. This works fine:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <CheckBox IsChecked="{Binding IsOpen, ElementName=infobox, Mode=TwoWay}" Content="IsOpen" VerticalAlignment="Top" /> <TextBlock x:Name="relative" Text="RelativeToElement" VerticalAlignment="Center" HorizontalAlignment="Center" />
<ig:XamInfoBox x:Name="infobox" IsClosedOnOutsideTap="False" RelativeToElement="{Binding ElementName=relative}"> <TextBlock Text="InfoBox!" Padding="20" /> </ig:XamInfoBox>
</Grid>
Can you provide us more details on how you are using it? If you are binding it to a ViewModel, that's properly implementing INotifyPropertyChanged and with a TwoWay binding, it should work..
Thanks,
Andres
When I use a CheckBox with Element binding, then open/close works, but it doesn't in my scenario.
Some differences are:
<Canvas x:Name="LayoutRoot">
...<ig:XamInfoBox x:Name="infoBox" IsClosedOnOutsideTap="False" IsClosedOnBackButton="False" RelativeToElementPlacement="Top" PointerShape="CurlyPointer" DisconnectedPointerOffset="0" RelativeToElement="{Binding ElementName=dial}" PointerLength="40" PointerOffset="1" Background="#FF9D2F14" PointerBackground="#FF9D2F14" IsOpen="{Binding IsShowBubble, Mode=TwoWay}">
<TextBlock Foreground="White" TextWrapping="Wrap" Text="{Binding MyValue}" Width="80" HorizontalAlignment="Center" FontSize="32" TextAlignment="Center" FontWeight="Bold"/>
</StackPanel>
</ig:XamInfoBox>
<Button Canvas.Left="31" Canvas.Top="62" Content="Button" Height="76" Name="ShowBubble" Width="102" />
private
bool isShowBubble;
public
bool IsShowBubble{
get { return isShowBubble; }
set {
{
isShowBubble =
value;
NotifyOfPropertyChange(() => IsShowBubble);
}
void ShowBubble() { IsShowBubble = !IsShowBubble; }