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; }
We were able to reproduce the issue. It's a bug, as the IsOpen property is losing the binding. We are opening a support case and log a bug for this.
As a workaround, in order to not to set the property in the code-behind and break your MVVM, you can use the following class that defines an attached property that you can bind:
public class InfoBoxIsOpenWrapper : FrameworkElement
public static bool GetIsOpen(DependencyObject obj)
return (bool)obj.GetValue(IsOpenProperty);
public static void SetIsOpen(DependencyObject obj, bool value)
obj.SetValue(IsOpenProperty, value);
// Using a DependencyProperty as the backing store for IsOpen. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsOpenProperty =
DependencyProperty.RegisterAttached("IsOpen", typeof(bool), typeof(InfoBoxIsOpenWrapper), new PropertyMetadata(IsOpenPropertyChanged));
private static void IsOpenPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
var infoBox = (XamInfoBox) d;
infoBox.IsOpen = (bool) e.NewValue;
<ig:XamInfoBox x:Name="infobox" IsClosedOnOutsideTap="False" RelativeToElement="{Binding ElementName=relative}"
InfoBoxClose:InfoBoxIsOpenWrapper.IsOpen="{Binding IsShowBubble}">
<TextBlock Text="InfoBox!" Padding="20"/>
Let me know if it works for you.
I apologize for the inconveniences.
Hello rmtuckerphx,
Regarding Andres comments below, I have created a support case CAS-70733-T97JGN. I have also logged this as a development issue in our system with the issue ID 84837. I will send you more details regarding this development issue through the support case.
aaguiar said: Hi, We were able to reproduce the issue. It's a bug, as the IsOpen property is losing the binding. We are opening a support case and log a bug for this .Andres
We were able to reproduce the issue. It's a bug, as the IsOpen property is losing the binding. We are opening a support case and log a bug for this
.Andres
Please let me know if you have any questions on this matter.