Windows Phone,动感风格

发布于 2024-10-31 01:47:05 字数 351 浏览 1 评论 0原文

我正在开发一个应用程序,我希望一些边框的颜色根据用户选择的主题而改变。边框部分放置在 xaml 中,但也会根据用户所做的选择在整个应用程序中动态生成。我还使用了一些 LoopingSelector 控件(来自 Silverlight 工具包),它们反过来也生成边框。

所以,我想知道我应该如何解决这个问题。最初,我尝试将样式应用于边框,然后根据主题的选择更改样式,但显然样式在运行时是只读的。我还认为我可以迭代并更改边框的颜色,但 LoopingSelector 似乎没有公开其边框的该属性,或者实际上根本没有公开控件。

所以我认为我应该以某种方式使用绑定,但由于我对 Silverlight 还很陌生,所以我不太确定如何去做。

提前致谢。

I'm working on an app where I want the color of a few borders to change depending on the users choice of theme. The borders are partly placed in the xaml, but also dynamically generated throughout the app depending on choices the user make. I am also using a few LoopingSelector controls (from the Silverlight toolkit), that in turn also generate borders.

So, I was wondering how I should approach this problem. Initially I tried applying a style to the borders, and then changing the style depending on the choice of theme, but apparently styles are read-only during run time. I also figured I could iterate through and change the color of the borders, but it seems the LoopingSelector doesn't expose that property of its borders, or really, expose the controls at all.

So I assume I should use binding in some way, but as I'm still quite new to Silverlight I'm not really sure how to go about that.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彼岸花似海 2024-11-07 01:47:05

如果您有一个命名资源(例如 CustomBorderBrush),您在 XAML 中将其用于 XAML 中的部分,那么您可以从应用程序的资源访问此画笔:

Border newBorder = new Border();
newBorder.BorderBrush = (Brush)Application.Current.Resources["CustomBorderBrush"];

如果您还有问题使用 LoopingSelector,那么这是一个单独的问题:) 听起来您需要将自己的样式应用于 LoopingSelector,以便您可以指定所需的画笔值。

If you have a named resource, say CustomBorderBrush, that you are using in your XAML for the parts that are in the XAML, then you can access this brush from the Application's resources:

Border newBorder = new Border();
newBorder.BorderBrush = (Brush)Application.Current.Resources["CustomBorderBrush"];

If you additionally have a problem with the LoopingSelector, then that's a separate issue :) It sounds like you need to apply your own style to the LoopingSelector so that you can specify the brush value that you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文