Answer the question
In order to leave comments, you need to log in
User Control need to flip properties?
Hello, there are 2 questions about UserControl.
Here I have a control, I added a couple of DependencyProperty to it and made some EditableTextBlock when double-clicking, the IsEditMode property changes and the TextBox is hidden / shown, everything works, I got what I wanted, but besides these properties, I want to change some more properties
1) Is it really so it is necessary to forward all properties everywhere? in the example, only the font, but there can be a lot of things.
<UserControl
x:Class="SlideMenu.Controls.EditableTextBlock"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SlideMenu.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="uc"
d:DesignHeight="25"
d:DesignWidth="100"
mc:Ignorable="d">
<Grid>
<TextBlock
FontFamily="{Binding ElementName=uc, Path=FontFamily}"
FontSize="{Binding ElementName=uc, Path=FontSize}"
FontWeight="{Binding ElementName=uc, Path=FontWeight}"
MouseDown="TextBlock_MouseDown"
Text="{c:Binding ElementName=uc,
Path=Text}"
TextAlignment="{Binding ElementName=uc, Path=TextAlignment}" />
<TextBox
FontFamily="{Binding ElementName=uc, Path=FontFamily}"
FontSize="{Binding ElementName=uc, Path=FontSize}"
FontWeight="{Binding ElementName=uc, Path=FontWeight}"
MouseDoubleClick="TextBox_MouseDoubleClick"
Text="{c:Binding ElementName=uc,
Path=Text}"
TextAlignment="{Binding ElementName=uc, Path=TextAlignment}"
Visibility="{c:Binding ElementName=uc,
Path=IsEditMode}" />
</Grid>
</UserControl>
<Controls:EditableTextBlock Grid.Column="1" Text="ASDHAJSHDGA" HorizontalAlignment="Left" Width="108">
qwhuejghhqwe
</Controls:EditableTextBlock>
Answer the question
In order to leave comments, you need to log in
1) Yes, but this can be simplified using the DataContext, you can bind everything you need through the ViewModel without the Dependency Property
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question