将内部枚举'TileLayoutIndex'转换为int

时间:2015-05-17 20:31:03

标签: c# microsoft-band

我收到有关转换为int的错误消息。

以下是代码:

// create the object containing the page content to be set
PageData pageContent = new PageData(
    messagesPageGuid,        
    TileLayoutIndex.MessagesLayout, // Specify which layout to use for this page
    new WrappedTextBlockData(
        (Int16)TileMessagesLayoutElementId.Message1,
        "This is the text of the first message"),
    new WrappedTextBlockData(
        (Int16)TileMessagesLayoutElementId.Message2,
        "This is the text of the second message"));

这是内部枚举代码:

internal enum TileLayoutIndex
{
    MessagesLayout = 0,
};

为什么我收到错误?

更新

Guid messagesPageGuid = Guid.NewGuid();

// create the object containing the page content to be set
PageData pageContent = new PageData(
    messagesPageGuid,

这个Guid可能是问题

1 个答案:

答案 0 :(得分:1)

您没有使用整数,因此您需要投射它:

// create the object containing the page content to be set
PageData pageContent = new PageData(
    messagesPageGuid,        
    (int)TileLayoutIndex.MessagesLayout, // Specify which layout to use for this page