首页 新闻 会员 周边

大家好,请教一下动态加载按钮样式的功能的实现。谢谢。

0
悬赏园豆:100 [已关闭问题]

  我现在需要实现一个动态加载按钮样式的功能,不同的按钮显示不同的样式(由配置来决定)。 并且不同的样式存放在不同的XAML的文件里。具体如下:
样式资源文件是用Microsoft Expression Design 2生成的,并且有多个这样的文件,例如:
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 <DrawingBrush x:Key="ButtonStyle" Stretch="Uniform">
  <DrawingBrush.Drawing>
   <DrawingGroup>
    <DrawingGroup.Children>
     <GeometryDrawing Brush="#FFFE0000" Geometry="F1 M 50,0C 77.6142,0 100,22.3858 100,50C 100,77.6142 77.6142,100 50,100C 22.3858,100 0,77.6142 0,50C 0,22.3858 22.3858,0 50,0 Z "/>
    </DrawingGroup.Children>
   </DrawingGroup>
  </DrawingBrush.Drawing>
 </DrawingBrush>
</ResourceDictionary>

展现界面是:
 <Button Height="50" Width="50" Margin="2"  >
                <Button.Template>
                    <ControlTemplate>
                        <Grid>
                            <Rectangle Fill="{Binding Path=Style}" />             
                        </Grid>
                    </ControlTemplate>
                </Button.Template>              
   </Button>
 

现在我的问题是要怎么样将资源文件的内容动态加载到按钮上来?      
因为这个按钮的样式是不定的,有可能是A样式,也有可能是B样式,样式都是存放在不同的XAML的资源文件上。

如果你有空,麻烦你帮我解答 一下。谢谢。。

时间太快了的主页 时间太快了 | 初学一级 | 园豆:45
提问于:2010-03-09 14:44
< >
分享
其他回答(2)
0

貌似可以把资源merge到application中 然后用datatrigger或者其他trigger动态切换

黄泉天上来 | 园豆:230 (菜鸟二级) | 2010-03-09 17:14
0
helloj2ee | 园豆:255 (菜鸟二级) | 2010-03-09 19:45
你的例子很好,但不是我想要实现的要求,我现在实现了,非常感谢。
支持(0) 反对(0) 时间太快了 | 园豆:45 (初学一级) | 2010-03-11 10:55
0
西越泽 | 园豆:10775 (专家六级) | 2010-03-09 22:04
你的例子很好,但不是我想要实现的要求,我现在实现了,非常感谢。
支持(0) 反对(0) 时间太快了 | 园豆:45 (初学一级) | 2010-03-11 10:55
谢谢推荐。
支持(0) 反对(0) 时间太快了 | 园豆:45 (初学一级) | 2010-03-11 10:55
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册