如何将控件定义为资源,然后将其放置到窗体上?



我想这样做:

<Window x:Class="WpfApplication10.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <Button x:Key="butt" Content="Yeah!" />
    </Window.Resources>
    <Grid>
        <!-- Place button here -->
    </Grid>
</Window>

怎么做?我想在单个文件中创建小型用户控件库。

<Grid>
    <StaticResource ResourceKey="butt"/>
</Grid>

应该工作…

最新更新