PDA

View Full Version : سوال: دو ستونه کردن تولبار در WPF



mostafab2m
جمعه 29 اسفند 1393, 04:05 صبح
سلام خدمت دوستان
تو پروژه جدیدم نیاز به یه نوار ابزار مثل نوار ابزار فتوشاپ دارم
از یه toolbar استفاده کردم و هر یک از آیکونهای ابزارم رو داخل
داخل یک Radio Button قرار دادم تا به صورت هم زمان کاربر نتونه دو تا
ابزار رو انتخاب کنه، میخوام بدونم چطور میتونم تولبارم رو دو ستونه
کنم ؟؟؟
البته اینو میدونم که میتونم توی toolbar یه grid یا wrappanel یا ....
قرار بدم تا تولبار رو به دو ستون تقسیم کنه اما اونجوری مشکلی که بوجود میاد
اینه Radio Button هام کنارش اون دایره چک مارک کردن اضافه میشه
لطفا راهنماییم کنید.
129599


<ToolBarTray >
<ToolBar >
<RadioButton >
<Rectangle Fill="Gray" Stroke="AliceBlue" Width="20" Height="20"/>
</RadioButton>
<RadioButton >
<Rectangle Fill="Gray" Stroke="AliceBlue" Margin="0,0,0,12" Width="20" Height="20"/>
</RadioButton>
<ToolBar >
<ToolBarTray >

---------------------------------------------------------------
129600


<ToolBarTray >
<ToolBar >
<wrappanel>
<RadioButton >
<Rectangle Fill="Gray" Stroke="AliceBlue" Width="20" Height="20"/>
</RadioButton>
<RadioButton >
<Rectangle Fill="Gray" Stroke="AliceBlue" Margin="0,0,0,12" Width="20" Height="20"/>
</RadioButton>
</wrappanel>
<ToolBar >
<ToolBarTray >

میخوام اینجوری بشه
129601

sadeghmosavi539
جمعه 29 اسفند 1393, 15:34 عصر
می تونی از دو تا StackPanel استفاده کنی که orientation هردوشون vertical است.

Mori Bone
جمعه 29 اسفند 1393, 16:09 عصر
سلام عزیز. اینو استفاده کن مشکلی بود در خدمتم.



<ToolBar>
<WrapPanel
Width='123'>
<WrapPanel.Resources>
<Style
TargetType='RadioButton'
x:Key='toolsstyle'>
<Setter
Property='Cursor'
Value='Hand' />
<Setter
Property='HorizontalContentAlignment'
Value='Center' />
<Setter
Property='VerticalContentAlignment'
Value='Center' />
<Setter
Property='Width'
Value='50' />
<Setter
Property='Height'
Value='50' />
<Setter
Property='Margin'
Value='5' />
<Setter
Property='Background'
Value='{x:Null}' />
<Setter
Property='BorderThickness'
Value='0' />
<Setter
Property='BorderBrush'
Value='#2d2d30' />
<Setter
Property='Template'>
<Setter.Value>
<ControlTemplate
TargetType='{x:Type RadioButton}'>
<Grid
x:Name='templateRoot'
Background='Transparent'
SnapsToDevicePixels='True'>
<Border
BorderBrush='{TemplateBinding BorderBrush}'
BorderThickness='{TemplateBinding BorderThickness}'
Width='{TemplateBinding Width}'
Height='{TemplateBinding Height}'
x:Name='border'
Background='{TemplateBinding Background}'
CornerRadius='5'
HorizontalAlignment='{TemplateBinding HorizontalContentAlignment}'
VerticalAlignment='{TemplateBinding VerticalContentAlignment}'>
<ContentPresenter
x:Name='contentPresenter'
ContentTemplate='{TemplateBinding ContentTemplate}'
Content='{TemplateBinding Content}'
Grid.Column='1'
ContentStringFormat='{TemplateBinding ContentStringFormat}'
Focusable='False'
HorizontalAlignment='{TemplateBinding HorizontalContentAlignment}'
Margin='{TemplateBinding Padding}'
RecognizesAccessKey='True'
SnapsToDevicePixels='{TemplateBinding SnapsToDevicePixels}'
VerticalAlignment='{TemplateBinding VerticalContentAlignment}' />
</Border>

</Grid>
<ControlTemplate.Triggers>
<Trigger
Property='HasContent'
Value='True'>
<Setter
Property='FocusVisualStyle'>
<Setter.Value>
<Style>
<Setter
Property='Control.Template'>
<Setter.Value>
<ControlTemplate>
<Rectangle
SnapsToDevicePixels='True'
Stroke='{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}'
StrokeThickness='1'
StrokeDashArray='1 2' />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Trigger>
<Trigger
Property='IsMouseOver'
Value='True'>
<Setter
Property='Border.BorderThickness'
TargetName='border'
Value='1' />
</Trigger>
<Trigger
Property='IsEnabled'
Value='False'>
</Trigger>
<Trigger
Property='IsPressed'
Value='True'>
</Trigger>
<Trigger
Property='IsChecked'
Value='True'>
<Setter
Property='Border.BorderThickness'
TargetName='border'
Value='2' />
</Trigger>
<Trigger
Property='IsChecked'
Value='{x:Null}'>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</WrapPanel.Resources>
<RadioButton
Style='{StaticResource toolsstyle}'
Content='ابزار یک'/>
<RadioButton
Style='{StaticResource toolsstyle}'
Content='ابزار دو' />
<RadioButton
Style='{StaticResource toolsstyle}'
Content='ابزار سه' />
<RadioButton
Style='{StaticResource toolsstyle}'
Content='ابزار چهار' />
</WrapPanel>

</ToolBar>

mostafab2m
شنبه 01 فروردین 1394, 15:22 عصر
Mori Bone (http://barnamenevis.org/member.php?289901-Mori-Bone) مرسی واقعا به بهترین روش راهنماییم کردی
فقط امکانش هست جای کلمه "ابزار یک" از یک عکس استفاده کرد؟
اگه یه توضیح کلی هم بدی کد رو دیگه خیلی لطف کردی

Mori Bone
سه شنبه 04 فروردین 1394, 12:25 عصر
<WrapPanel
Width='60'>
<WrapPanel.Resources>
<Style
TargetType='RadioButton'
x:Key='toolsstyle'>
<Setter
Property='Cursor'
Value='Hand' />
<Setter
Property='HorizontalContentAlignment'
Value='Center' />
<Setter
Property='VerticalContentAlignment'
Value='Center' />
<Setter
Property='Width'
Value='50' />
<Setter
Property='Height'
Value='50' />
<Setter
Property='Margin'
Value='5' />
<Setter
Property='Background'
Value='{x:Null}' />
<Setter
Property='BorderThickness'
Value='0' />
<Setter
Property='BorderBrush'
Value='#2d2d30' />
<Setter
Property='Template'>
<Setter.Value>
<ControlTemplate
TargetType='{x:Type RadioButton}'>
<Grid
x:Name='templateRoot'
Background='Transparent'
SnapsToDevicePixels='True'>
<Border
BorderBrush='{TemplateBinding BorderBrush}'
BorderThickness='{TemplateBinding BorderThickness}'
Width='{TemplateBinding Width}'
Height='{TemplateBinding Height}'
x:Name='border'
Background='{TemplateBinding Background}'
CornerRadius='5'
HorizontalAlignment='{TemplateBinding HorizontalContentAlignment}'
VerticalAlignment='{TemplateBinding VerticalContentAlignment}'>
<ContentPresenter
x:Name='contentPresenter'
ContentTemplate='{TemplateBinding ContentTemplate}'
Content='{TemplateBinding Content}'
Grid.Column='1'
ContentStringFormat='{TemplateBinding ContentStringFormat}'
Focusable='False'
HorizontalAlignment='{TemplateBinding HorizontalContentAlignment}'
Margin='{TemplateBinding Padding}'
RecognizesAccessKey='True'
SnapsToDevicePixels='{TemplateBinding SnapsToDevicePixels}'
VerticalAlignment='{TemplateBinding VerticalContentAlignment}' />
</Border>

</Grid>
<ControlTemplate.Triggers>
<Trigger
Property='HasContent'
Value='True'>
<Setter
Property='FocusVisualStyle'>
<Setter.Value>
<Style>
<Setter
Property='Control.Template'>
<Setter.Value>
<ControlTemplate>
<Rectangle
SnapsToDevicePixels='True'
Stroke='{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}'
StrokeThickness='1'
StrokeDashArray='1 2' />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Trigger>
<Trigger
Property='IsMouseOver'
Value='True'>
<Setter
Property='Border.BorderThickness'
TargetName='border'
Value='1' />
</Trigger>
<Trigger
Property='IsEnabled'
Value='False'>
</Trigger>
<Trigger
Property='IsPressed'
Value='True'>
</Trigger>
<Trigger
Property='IsChecked'
Value='True'>
<Setter
Property='Border.BorderThickness'
TargetName='border'
Value='2' />
</Trigger>
<Trigger
Property='IsChecked'
Value='{x:Null}'>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</WrapPanel.Resources>
<RadioButton
Style='{StaticResource toolsstyle}'>
<Image />
</RadioButton>
<RadioButton
Style='{StaticResource toolsstyle}'>
<Image />
</RadioButton>
<RadioButton
Style='{StaticResource toolsstyle}'>
<Image />
</RadioButton>
<RadioButton
Style='{StaticResource toolsstyle}'>
<Image />
</RadioButton>
</WrapPanel>

mostafab2m
جمعه 07 فروردین 1394, 20:28 عصر
مرسی لطف کردی کارم راه افتاد

Mori Bone
جمعه 07 فروردین 1394, 23:49 عصر
مرسی لطف کردی کارم راه افتاد

خواهش میکنم. قصد منم از دادن این کد راه افتادن کار شما بود. یه خورده کار کنید میفهمید که کد من همچین کامل کامل هم نیست:چشمک: