-2
Я действительно не понимаю, почему я наклоняю связывании, как это:WPF Короткое связывание
<Label Content="{Binding SomeObiect}"/>
В очень часто вижу что-то вроде этого, но в моих программах не работают ... Почему? :(
<UserControl x:Class="GAME___ala_Mario.View.Controls.SkillButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Converers="clr-namespace:GAME___ala_Mario.View.Converters"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" Name="btn_Skill">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20*"/>
<RowDefinition Height="5*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<!--Tło-->
<Viewbox Grid.Column="0" Grid.Row="0"
Grid.ColumnSpan="2" Grid.RowSpan="2">
<!-- AND I USE BINDING LIKE IT: (always) -->
<Image Source="{Binding ElementName=btn_Skill, Path=BackgroundImageSource}"/>
</Viewbox>
</Grid>
</UserControl>
И Code-за:
public partial class SkillButton : UserControl
{
[...]
public static readonly DependencyProperty BackgroundImageSourceProperty = DependencyProperty.Register("BackgroundImageSource", typeof(ImageSource), typeof(SkillButton));
public ImageSource BackgroundImageSource
{
get { return (ImageSource)GetValue(BackgroundImageSourceProperty); }
set { SetValue(BackgroundImageSourceProperty, value); }
}
}