【发布时间】:2015-02-02 04:37:03
【问题描述】:
我有一个非常简单的 XAML Visibility="Collapsed" X1="1" Margin="-35 0 0 0" Y1="0.4">
<Label.Content>
<Slider Grid.Column="0"
Width="20"
Height="65"
IsDirectionReversed="True"
Maximum="0.1"
Minimum="-4"
Orientation="Vertical"
x:Name="Slider1"
Value="{Binding Source={x:Reference scaleFactorModifier},
Path=ZoomScaleFactor, Mode=TwoWay}" />
</Label.Content>
</Label>
</SciChart:CustomAnnotation.Content>
</SciChart:CustomAnnotation>
现在由于某种原因,我需要从后面的代码中设置 CustomControl.Content 属性。有没有可能我将所有标签控件移动到某个样式和模板,并在运行时使用该特定样式或模板设置 CustomControl 内容属性。
更新
使用 Code behind 的原因
实际上,我的控件中有 Annotations 属性,可以根据需要在其中包含任何控件。以前我在控件中使用硬编码注释并手动放置控件。现在我想绑定 Annotations 属性。我可以创建这种类型的属性并在其中添加 CustomAnnotation 对象。但是customAnnotation对象里面需要有标签和其他控件,我该怎么做呢?
【问题讨论】:
-
可能是XY problem。为什么要从代码隐藏中设置一些东西?
-
@dymanoid 嗨,我明白你的意思并更新我的问题并提到 X 而不是问 Y。请看一下。
标签: c# wpf binding controltemplate