Here is the code I want to post

<UserControl.Resources>
        <DataTemplate x:Name="DefaultWideSideItemTemplate" x:DataType="ui:AppMenuItem">
            <Grid>
                <ui:ButtonWithIcon IconContent="{x:Bind Icon}"
                                       Content="{x:Bind Name}"
                                       Style="{StaticResource TransparentFontButtonStyle}"
                />
            </Grid>
        </DataTemplate>
        <others:SideMenuItemTemplateSelector DefaultTemplate="{StaticResource DefaultWideSideItemTemplate}" x:Key="WideSideItemTemplateSelector"/>
    </UserControl.Resources>

<ListView Style="{StaticResource HorizontalCenterListView}" 
                  IsItemClickEnabled="True"
                  ItemsSource="{x:Bind MenuItemCollection}"
                  VerticalAlignment="Top"
                  x:Name="SideMenuListView"
                  Loaded="SideMenuListView_Loaded"
                  ItemClick="SideMenuListView_ItemClick"
                  ItemTemplateSelector="{StaticResource WideSideItemTemplateSelector}">
            </ListView>



----
public class CustomDirectRouteProvider : DefaultDirectRouteProvider
{
    protected override System.Collections.Generic.IReadOnlyList<IDirectRouteFactory>

    GetActionRouteFactories(HttpActionDescriptor actionDescriptor)
    {
        // inherit route attributes decorated on base class controller's actions
        return actionDescriptor.GetCustomAttributes<IDirectRouteFactory>
        (inherit: true);
    }
}

public class Startup
{
    public static void Configuration(IAppBuilder appBuilder)
    {
        using (var config = new HttpConfiguration())
        {
            config.EnableSwagger(c => c.SingleApiVersion("v1", "MyAPI"))
                .EnableSwaggerUi();

            config.MapHttpAttributeRoutes(new CustomDirectRouteProvider());
            config.EnableCors();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            config.AddODataQueryFilter();
            config.Formatters.Clear();

            config.Count().Filter().OrderBy().Expand().Select().MaxTop(null)
                .EnableDependencyInjection();

            config.Formatters.Add(new System.Net.Http.Formatting.JsonMediaTypeFormatter
            {
                UseDataContractJsonSerializer = false,
                SerializerSettings = new JsonSerializerSettings
                {
                    ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(),
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                    DateFormatHandling = DateFormatHandling.IsoDateFormat,
                    DateParseHandling = DateParseHandling.DateTimeOffset,
                    DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind,
                    Formatting = Formatting.None,
                    NullValueHandling = NullValueHandling.Ignore
                }
            });

            config.Formatters.Add(new System.Net.Http.Formatting.BsonMediaTypeFormatter());
            appBuilder.UseWebApi(config);
        };
    }
}

Comments

Be the first to post a comment

Post a comment