Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

how to translate WPF xaml code into code behind c#?

$
0
0

moreover,

Error2The name "DivideBy2Converter" does not exist in the namespace "clr-namespace:TestCanvas".

namespace TestCanvas
{

    #region --- DivideBy2Converter ---

<Window x:Class="TestCanvas.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="700" Width="900"
        xmlns:local="clr-namespace:TestCanvas"><local:DivideBy2Converter x:Key="divideBy2Converter"/><local:BoolToVisibilityConverter x:Key="boolToVisibilityConverter"/><local:CenterPointConverter x:Key="centerPointConverter"/><local:TwoShapesPerimeterConverter x:Key="twoShapesPerimeterConverter"/>

MultiBinding multiBinding = new MultiBinding();
multiBinding.Converter = new CenterPointConverter();

multiBinding.Bindings.Add(new Binding("rct") { Path = "RenderTransform" });
multiBinding.Bindings.Add(new Binding("rct") { Path = "Width" });
multiBinding.Bindings.Add(new Binding("rct") { Path = "Height" });

multiBinding.NotifyOnSourceUpdated = true;//this is important.
line.SetBinding(Line., multiBinding);

from

<Line StrokeThickness="1" Stroke="Red" Panel.ZIndex="2"><Line.X1><MultiBinding Converter="{StaticResource centerPointConverter}"
                                   ConverterParameter="True"><Binding ElementName="rct" Path="RenderTransform"/><Binding ElementName="rct" Path="Width"/><Binding ElementName="rct" Path="Height"/></MultiBinding></Line.X1><Line.Y1><MultiBinding Converter="{StaticResource centerPointConverter}"
                                   ConverterParameter="False"><Binding ElementName="rct" Path="RenderTransform"/><Binding ElementName="rct" Path="Width"/><Binding ElementName="rct" Path="Height"/></MultiBinding></Line.Y1><Line.X2><MultiBinding Converter="{StaticResource
                         }"
                                   ConverterParameter="True"><Binding ElementName="el" Path="RenderTransform"/><Binding ElementName="el" Path="Width"/><Binding ElementName="el" Path="Height"/></MultiBinding></Line.X2><Line.Y2><MultiBinding Converter="{StaticResource
}"
                                   ConverterParameter="False"><Binding ElementName="el" Path="RenderTransform"/><Binding ElementName="el" Path="Width"/><Binding ElementName="el" Path="Height"/></MultiBinding></Line.Y2></Line>


New


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>