3
이미지 컨트롤에 URI를 지정하고 싶습니다. 다음 XAML은 UserControl에 있습니다.컨트롤 템플릿에서 속성 설정
public string ImageUrl
{
get { return (string)GetValue(ImageUrlProperty); }
set { SetValue(ImageUrlProperty, value); }
}
// Using a DependencyProperty as the backing store for ImageUrl. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ImageUrlProperty =
DependencyProperty.Register("ImageUrl", typeof(string), typeof(ImageControl), new PropertyMetadata(""));
의 ControlTemplate에 내 이미지의 원본 속성을 할당하는 가장 좋은 방법은 무엇입니까 :
<StackPanel>
<Button Command="{StaticResource ImageClick}" x:Name="imageButton">
<Button.Template>
<ControlTemplate>
<Grid>
<Image MaxHeight="100" MaxWidth="300" x:Name="image" />
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
나는에서 이미지의 URL과 종속성 속성 코드 숨김 있나요?