powered by simpleCommunicator - 2.0.59     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Specified element is already the logical child of another element. Disconnect it first.
1 сообщений из 1, страница 1 из 1
Specified element is already the logical child of another element. Disconnect it first.
    #37134266
sealmu
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
В отдельной сборке я определяю ResourceDictionary
с стилем для Content кнопки :

Код: csharp
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
<ResourceDictionary xmlns=" http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                    xmlns:x=" http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:local="clr-namespace:Keyboard_Standard;assembly=Keyboard_Standard" >

    <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type local:Keyboard_Standard}, 
                ResourceId=Button_1_Content}" >

        <Setter Property="Button.Content">
            <Setter.Value>

                   ............................................................

            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

и ComponentResourceKey.


Затем в окне добавляю :

Код: csharp
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
<Window x:Class="NoName1.MainWindow"
        xmlns=" http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x=" http://schemas.microsoft.com/winfx/2006/xaml" 
        Title="MainWindow" Height="350" Width="525"
        xmlns:res="clr-namespace:Keyboard_Standard;assembly=Keyboard_Standard">

    <Window.Resources>
        <SolidColorBrush x:Key="Red">Red</SolidColorBrush>
    </Window.Resources>
        
    <Grid>

        ........................................

            <Button Grid.Row="0" Width="150" Height="50"
                    Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type res:Keyboard_Standard}, 
                        ResourceId=Button_1_Content}}"></Button>

            <Button Grid.Row="1" Width="150" Height="50"
                    Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type res:Keyboard_Standard}, 
                        ResourceId=Button_1_Content}}"></Button>
                  ..........................................


И если добавить больше одной кнопки -> получаем ошибку :
Specified element is already the logical child of another element. Disconnect it first.

с одной кнопкой все нормально.

Как это решить?
...
Рейтинг: 0 / 0
1 сообщений из 1, страница 1 из 1
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Specified element is already the logical child of another element. Disconnect it first.
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]