I'm trying to define a database for labels. Is this possible? Since I could not find anything useful to move forward, so I defined a control template and tried to work. Unfortunately, when I compose two objects, in this way I get a label that does not show anything, even if the object with a given parameter has been successfully labeled with the code back to the label. help please!
& lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "Label" & gt; & Lt; Border & gt; & Lt; Grid & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; Column define width = "auto" & gt; & Lt; / ColumnDefinition & gt; & Lt; Column define width = "auto" & gt; & Lt; / ColumnDefinition & gt; & Lt; /Grid.ColumnDefinitions> & Lt; TextBlock background = "green" text = "{binding table name}" grid. Column = "0" & gt; & Lt; / TextBlock & gt; & Lt; Text block background = "red" text = "{binding column name}" grid. Column = "1" & gt; & Lt; / TextBlock & gt; & Lt; / Grid & gt; & Lt; / Border & gt; & Lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; Edited: The window's full XML. Resources have been requested
& lt; window. Resources & gt; & Lt; Style x: key = "myLabelTemplate" TargetType = "Label" & gt; & Lt ;! - & lt; Setter Property = "Background" value = "DarkView" & gt; & Lt; / Setter & gt; & Lt; Setter Property = "Foreground" Value = "White" & gt; & Lt; / Setter & gt; - & gt; & Lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "Label" & gt; & Lt; Border & gt; & Lt; Grid & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; Column define width = "auto" & gt; & Lt; / ColumnDefinition & gt; & Lt; Column define width = "auto" & gt; & Lt; / ColumnDefinition & gt; & Lt; /Grid.ColumnDefinitions> & Lt ;! - & lt; Textblocks background = "green" text = "{binding table name}" grid. Column = "0" & gt; & Lt; / TextBlock & gt; & Lt; Text block background = "red" text = "{binding column name}" grid. Column = "1" & gt; & Gt; / Textblocks & gt; - & gt; & Lt; / Grid & gt; & Lt; / Border & gt; & Lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt; & Lt ;! - & lt; ControlTemplate TargetType = "Label" x: Key = "tablelLabel" & gt; & Lt; Grid & gt; & Lt; Border Borderbrush = "{TemplateBinding BorderBrush}" Border Exits = "5" CornerReadia = "5" & gt; & Lt; Border.Background & gt; & Lt; Solid Colourbrush Color = "# 50000000" & gt; & Lt; / SolidColorBrush & gt; & Lt; /Border.Background> & Lt; / Border & gt; & Lt; Grid & gt; & Lt; Grid.Background & gt; & Lt; LinearGradientBrush StartPoint = "0.5,0" Endpoint = "0.5.1" & gt; & Lt; GradientStop color = "transparent" offset = "0" /> & Lt; GradientStop Color = "Black" offset = "1" /> & Lt; GradientStop color = "transparent" offset = "1" /> & Lt; / LinearGradientBrush & gt; & Lt; /Grid.Background> & Lt; / Grid & gt; & Lt; / Grid & gt; & Lt; / ControlTemplate & gt; - & gt; & Lt; ControlTemplate TargetType = "Label" x: Key = "GeneralLabel" & gt; & Lt; Grid & gt; & Lt; Border Borderbridge = "# 34B7EEE" Bordercutness = "3" CornerReadia = "5" & gt; & Lt; / Border & gt; & Lt; / Grid & gt; & Lt; / ControlTemplate & gt; & Lt; /Window.Resources> You have to change the binding as follows:
& Lt; TextBlock background = "green" text = "{binding source = {static resource data}, path = tagname}" grid. Column = "0" /> & Lt; TextBlock background = "red" text = "{binding source = {static resource data}, path = columnname}" grid. Column = "1" & gt; & Lt; / TextBlock & gt; I tried to get the modified code two properties with a simple class and it worked successfully.
ObjectDataProvider was referenced as follows:
& lt; ObjectDataProvider x: key = "data" object type = "{x: type local: MyClass}" & gt; & Lt; / ObjectDataProvider & gt;
Comments
Post a Comment