How to make XAML code in C#


  • How would I convert this to C# code?

    <Style x:Key="seriesStyle" TargetType="{x:Type dxc:XYSeries2D}">
                <Setter Property="ArgumentDataMember" Value="Arguments" />
                <Setter Property="ValueDataMember" Value="Values" />
                <Setter Property="CrosshairLabelPattern" Value="{}{A} : {V:c}" />

    Thursday, March 08, 2018 10:05 PM


  • Hi,

    You can easily get the defined style which is in Resource as below.

    Style style = this.FindResource("seriesStyle") as Style;
    xySeries2D.Style = style;

    or :

    Style style = Application.Current.FindResource("seriesStyle") as Style;
    xySeries2D.Style = style;

    If you really need create style in code behind, try something like:

      //define style in code
      Style style = new Style(typeof(TextBlock));
      style.Setters.Add(new Setter(XYSeries2D.ArgumentDataMember, Arguments));
      style.Setters.Add(new Setter(XYSeries2D.ValueDataMember, Values));
      style.Setters.Add(new Setter(XYSeries2D.CrosshairLabelPattern, "{}{A} : {V:c}"));
      //apply style
      xySeries2D.Style = style;

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Marked as answer by ttaylor29 Friday, March 09, 2018 6:03 PM
    Friday, March 09, 2018 1:54 AM