I have a WPF window that contains a Telerik RadPaneGroup, and in it I have a RadPanes:
<
telerik:RadPaneGroup
>
<
telerik:RadPane
x:Name
=
"ticketMapPane"
Header
=
"Map"
CanUserPin
=
"False"
CanFloat
=
"{Binding preferencesProperties.canFloatPanes}"
IsHidden
=
"{Binding Path=viewModel.stickyProperties.mapPaneVisible, RelativeSource={RelativeSource AncestorType=KtWpf:KorWindow}, Mode=TwoWay, Converter={StaticResource boolInverterConverter}}"
telerik:RadDocking.SerializationTag
=
"ticketMapPane"
>
<
local:TicketMap
x:Name
=
"ticketMap"
ticketMapType
=
"{Binding RelativeSource={RelativeSource AncestorType=KtWpf:KorWindow}, Path=viewModel.preferencesProperties.ticketMapType}"
/>
</
telerik:RadPane
>
</
telerik:RadPaneGroup
>
The ticketMapPane.IsHidden property is bound to the negation of stickyProperties.mapPaneVisible, so if mapPaneVisible is true, IsHidden is false, and the pane is displayed.
If mapPaneVisible is true on startup, ticketMapPane is visible, and ticketMap.ticketMapType is bound correctly to preferencesProperties.ticketMapType, and all is well with the world.
If I then manipulate the UI control that sets stickyProperties.mapPaneVisible to false the pane becomes invisible, if I set it to true the pane becomes visible again, and ticketMapType is bound correctly through it all.
But if stickyProperties.mapPaneVisible is false on startup, ticketMapPane is hidden, and ticketMapType doesn't seem to be bound.
I have a change handler on the ticketMapType property. It's called, when the ticketMapPane is visible on startup, and it is not, when it is not:
public
partial
class
TicketMap : KorUserControl
{
public
TicketMapType ticketMapType
{
get
{
return
(TicketMapType)GetValue(ticketMapTypeProperty); }
set
{ SetValue(ticketMapTypeProperty, value); }
}
public
static
readonly
DependencyProperty ticketMapTypeProperty =
DependencyProperty.Register(
"ticketMapType"
,
typeof
(TicketMapType),
typeof
(TicketMap),
new
PropertyMetadata(
new
PropertyChangedCallback(ticketMapTypePropertyChanged)));
private
static
void
ticketMapTypePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ticketMap = d
as
TicketMap;
if
(ticketMap !=
null
&& e.NewValue
is
TicketMapType)
{
var ticketMapType = (TicketMapType) e.NewValue;
ticketMap.setTicketMapType(ticketMapType);
}
}
[...]
}
So what is happening is that if the pane is hidden on startup, when I make it visible the TicketMap.ticketMapType contains the default value, and not the value that it was supposed to be bound to. If the pane is visible on startup, everything binds correctly.
So, the question - how do I get this to work?
I can see two possibilities:
- I get the binding to connect even though the pane is invisible, or
- I get the binding to connect when the pane is made visible.
Any ideas as to how to do either?