Question

I am new to XAML and am trying to create a basic Ribbon. I have some code here:

<RibbonWindow x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:r="clr-     namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
    Title="MainWindow"
    x:Name="RibbonWindow"
    Width="640" Height="480">

<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <Ribbon x:Name="Ribbon" Title="Ribbon Title">
        <r:RibbonButton Width="100" Background="Azure" Height="100" >

        </r:RibbonButton>
        <r:RibbonButton x:Name="RibbonButton" Label="Button" LargeImageSource="Icons/disk.png">


        </r:RibbonButton>

    </Ribbon>
</Grid>

I am getting an exception on the LargeImageSource part of the code. I am not sure why. The image is rendering in the designer and no errors are generated when I build but I can't run the project.

Here is the exception:

An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '19' and line position '51'.

If there is a handler for this exception, the program may be safely continued.

Any help would be appreciated.

Regards

Était-ce utile?

La solution

It has stopped producing the error (for some reason). It had something to do with using a .png file although I don't know what. I played around with the attributes and got it to work.

Autres conseils

Assuming "Icons/disk.png" is added to the solution explorer (right click on project -> Add -> New Folder, then right click on folder -> Add -> Existing Item... and select the image file), the item "disk.png" should have its properties set as follows:

Build Action : Content
Copy to Output Directory : Copy if newer
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top