【发布时间】:2015-07-30 02:22:28
【问题描述】:
在一个 Windows 商店应用项目中,我有一个 Flyout,具有某种风格
<Flyout>
...
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter">
<Setter Property="ScrollViewer.ZoomMode" Value="Enabled"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="5"/>
<Setter Property="MinHeight" Value="300"/>
<Setter Property="MinWidth" Value="300"/>
<Setter x:Name="FlyMargin" Property="Margin" Value="0,0,0,0"/>
</Style>
</Flyout.FlyoutPresenterStyle>
</Flyout>
我试图在后面的代码中以编程方式更改边距,但到目前为止我失败了
我试过这样:~
InfoFlyout.FlyoutPresenterStyle.Setters.Add(new Setter
{
Property = FlyoutPresenter.MarginProperty,
Value = "50,0,0,0"
});
它在我第一次调用弹出时有效,但第二次如果给出异常。 也尝试过类似的方法,但仍然不起作用
InfoFlyout.FlyoutPresenterStyle.Setters.ElementAt(6).SetValue(FlyoutPresenter.MarginProperty, "-28,125,0,0");
如何在后面的代码中更改 Margin Setter?
【问题讨论】:
标签: c# xaml windows-runtime windows-store-apps