我從DevExpress的團隊答覆如下這是爲我工作:
的Javascript
<script type="text/javascript">
function OnControlsInitialized(s, e) {
ASPxClientUtils.AttachEventToElement(window, "resize", function (evt) {
if (cp.InCallback())
return;
if (window.innerWidth <= 1100) {
if (RASPxMenuViewSetting.cpOrientation != "Vertical")
cp.PerformCallback("Vertical");
}
else
if (RASPxMenuViewSetting.cpOrientation != "Horizontal")
cp.PerformCallback("Horizontal");
});
}
</script>
ASPX文件
<dx:ASPxCallbackPanel ID="ASPxCallbackPanel1" runat="server" Width="200px" ClientInstanceName="cp" OnCallback="ASPxCallbackPanel1_Callback">
<PanelCollection>
<dx:PanelContent runat="server">
<dx:ASPxMenu ID="ASPxMenuViewSetting" runat="server" ClientInstanceName="RASPxMenuViewSetting" EnableTheming="True" ItemWrap="false">
<Items>
<dx:MenuItem Text="Item 1">
</dx:MenuItem>
<dx:MenuItem Text="Item 2">
</dx:MenuItem>
<dx:MenuItem Text="Item 3">
</dx:MenuItem>
<dx:MenuItem Text="Item 4">
</dx:MenuItem>
</Items>
</dx:ASPxMenu>
</dx:PanelContent>
</PanelCollection>
</dx:ASPxCallbackPanel>
<dx:ASPxGlobalEvents ID="ASPxGlobalEvents1" runat="server">
<ClientSideEvents ControlsInitialized="OnControlsInitialized" />
</dx:ASPxGlobalEvents>
,也需要改變CS文件如下:
protected void ASPxCallbackPanel1_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e)
{
if (e.Parameter == "Vertical")
ASPxMenuViewSetting.Orientation = Orientation.Vertical;
else
ASPxMenuViewSetting.Orientation = Orientation.Horizontal;
ASPxMenuViewSetting.JSProperties["cpOrientation"] = e.Parameter;
}