我在XAML中有这个
<ControlTemplate TargetType="{x:Type Button}">
<Image ...>
</ControlTemplate>
Run Code Online (Sandbox Code Playgroud)
我希望在C#代码中实现相同的功能.我怎样才能做到这一点?
ControlTemplate ct = new ControlTemplate();..
Image img = new Image();..
Run Code Online (Sandbox Code Playgroud)
现在如何将此图像分配给控制模板?我们能做到这一点还是我错过了这里的概念?
我有一个带有ItemsPanel的ListBox
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel x:Name="ThumbListStack" Orientation="Horizontal" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
Run Code Online (Sandbox Code Playgroud)
我想在后面的代码中使用TranslateTransform沿X轴移动堆栈面板.
问题是,我找不到Stack Panel.
ThumbListBox.FindName("ThumbListStack")
Run Code Online (Sandbox Code Playgroud)
什么都不返回 我想用它:
Storyboard.SetTarget(x, ThumbListBox.FindName("ThumbListStack"))
Run Code Online (Sandbox Code Playgroud)
如何获取堆栈面板,以便我可以将其与TranslateTransform一起使用
谢谢