i'm trying to style my image according to dependancy object i defined as followed:
in MainWindow.xaml:
<ObjectDataProvider x:Key="GetIsConnected"
ObjectType="{x:Type ConnectionRepository:ConnectionRepository}" />
<Image Name="ConnectStatusBarImage" Width="16" Height="16">
<Image.Style>
<Style>
<Setter Property="Image.Source" Value="/Images/connected16.png" />
<Style.Triggers>
<DataTrigger Binding="{Binding Source={StaticResource GetIsConnected}, Path=IsConnected}" Value="true">
<Setter Property="Image.Source" Value="/Images/disconnected16.png" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
the repository code looks like that:
public class ConnectionRepository : DependencyObject
{
public bool IsConnected
{
get { return (bool)GetValue(IsConnectedProperty); }
set { SetValue(IsConnectedProperty, value); }
}
}
public static readonly DependencyProperty IsConnectedProperty =
DependencyProperty.Register("IsConnected",
typeof(bool), typeof(ConnectionRepository));
i set the IsConnect to true if the connection succeeded.
but for some reason the image is not changing according to this object... and idea what is wrong ?