C# WPF: How do I Bind the content of a label to a value inside UserControl -
I want to be able to bind fc: ColorSlider to the value in my mainwindow.xaml, the following code is My ColorSlider.XAML
I want to bind text content with my redslider or RGB sliders. Normally this would be easy but my sliders are in a user tran and my textbox is in my main window.
& lt; Rectangle width = "165" horizontal alignment = "correct" grid. Column = "0" stroke = "black" & gt; & Lt; Rectangle.Fill & gt; & Lt; SolidColorBrush & gt; & Lt; SolidColorBrush.Color & gt; & Lt; Multiband Converter = "{static resource RgbConverter}" & gt; & Lt; Binding Path = "Price" element name = "RedSlider" /> & Lt; Binding Path = "Value" element name = "GreenSlider" /> & Lt; Binding path = "value" element name = "blueslider" /> & Lt; Binding path = "value" element name = "alpha_lider" /> & Lt; / MultiBinding & gt; & Lt ;! - Describes the color of the brush using RGB values; Each value has a limit of 0-255 - & gt; & Lt ;! - & lt; Color A = "255" R = "255" G = "0" B = "0" /> - & gt; & Lt; /SolidColorBrush.Color> & Lt; / SolidColorBrush & gt; & Lt; /Rectangle.Fill> & Lt; / Rectangles & gt;
This code is my MainWindow.XAML
& lt; Fc: ColorSlider grid. Column = "0" grid. Rows = "8" grid. Colspan = "2" x: name = "color slider" & gt; & Lt; / FC: ColorSlider & gt; & Lt; TextBox Grid.Row = "1" grid. Column = "0" width = "250" height = "auto" text = "hello" horizontal alignment = "center" margin = "6,0,2,0" & gt; & Lt; / Text box & gt; & Lt; Textbox Grid.Row = "2" Grid. Column = "0" width = "250" text = "{binding element name = colorful slider, path = red slider, mode = two}" horizontal alignment = "center" & gt; & Lt; / Text box & gt; & Lt; Text Box Grid Rau = "3" grid. Column = "0" width = "250" text = "hello" horizontal alignment = "center" & gt; & Lt; / Text box & gt; & Lt; Text Box Grid Rau = "4" grid. Column = "0" width = "250" text = "नमस्ते" horizontal alignment = "center" & gt; & Lt; / Textbox & gt; & Lt; Text box grid Rau = "1" grid. Column = "1" width = "250" text = "halo" horizontal alignment = "center" & gt; & Lt; / Text box & gt; & Lt; Text box grid Rau = "2" grid. Column = "2" width = "250" text = "halo" horizontal alignment = "center" & gt; & Lt; / Text box & gt; & Lt; Text Box Grid Rau = "3" grid. Column = "1" width = "250" text = "halo" horizontal alignment = "center" & gt; & Lt; / Text box & gt; & Lt; Text Box Grid Rau = "4" grid. Column = "1" width = "250" text = "नमस्ते" horizontal alignment = "center" & gt; & Lt; / Textbox & gt; & Lt; Checkbox Grid Column = "0" grid. Line = "5" horizontal align = "left" workspaceElement = "top" & gt; Display preview with sliders? & Lt; / Checkbox & gt;
Create an asset in the code behind your user control. Tie your control slider value to that property.
You should also be able to force it from your main window.
Comments
Post a Comment